package cn.com.headfree.userinfo.service.impl;

import java.util.*;
import java.util.stream.Collectors;

import cn.com.headfree.entity.*;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.gta.edu.sdk.common.dto.Page;
import com.gta.edu.sdk.util.IdGen;
import com.gta.edu.sdk.util.StringUtil;

import cn.com.headfree.drafts.service.IDraftsService;
import cn.com.headfree.entity.isc.User;
import cn.com.headfree.mouldshow.dao.HumanDataDao;
import cn.com.headfree.mouldshow.dao.TBusinessWorkflowBindDao;
import cn.com.headfree.recordlog.service.IRecordLogService;
import cn.com.headfree.userinfo.dao.IUserInfoDao;
import cn.com.headfree.userinfo.service.IUserInfoService;
import cn.com.headfree.util.SysDictionaryUtil;
import cn.com.headfree.vo.DeptIdPathVo;
import cn.com.headfree.vo.EachTypeDetailVo;
import cn.com.headfree.vo.FuturePostVo;
import cn.com.headfree.vo.SysDictionaryInfoVo;
import cn.com.headfree.vo.TEmpBaseInfoVo;
import cn.com.headfree.vo.complex.TAcadeAchiveInfoVo;
import cn.com.headfree.vo.complex.TPatentInfoVo;
import cn.com.headfree.vo.complex.TProjAchieveInfoVo;
import cn.com.headfree.vo.complex.TStandInfoVo;
import cn.com.headfree.vo.complex.TTecInnovInfoVo;
import cn.com.headfree.vo.complex.TTecManInnovVo;
import cn.com.headfree.workflow.dao.IWorkFlowDao;
import cn.com.headfree.workflow.service.IWorkFlowProcessService;
import cn.com.headfree.workflow.service.IWorkFlowService;
import cn.com.headfree.workflowant.service.IWorkFlowAntService;

@Service("userInfoService")
public class UserInfoServiceImpl implements IUserInfoService {
	@Autowired
	private IUserInfoDao userInfoDao;

	@Autowired
	private IWorkFlowDao workFlowDao;

	// 操作记录
	@Autowired
	private IRecordLogService recordLogService;

	@Autowired
	private IWorkFlowProcessService workFlowProcessService;

	@Autowired
	private IWorkFlowService workFlowService;

	@Autowired
	private HumanDataDao humanDataDao;

	@Autowired
	private TBusinessWorkflowBindDao tBusinessWorkflowBindDao;

	@Autowired
	private IWorkFlowAntService workFlowAntService;

	@Autowired
	private IDraftsService draftsService;

	// 基本信息
	@Value("${t_emp_base_info}")
	private String t_emp_base_info;
	// 年度绩效
	@Value("${t_year_effect_info}")
	private String t_year_effect_info;
	// 学历信息
	@Value("${t_educate_info}")
	private String t_educate_info;
	// 教育培训及授课经历
	@Value("${t_conti_study_info}")
	private String t_conti_study_info;
	// 专业技术资格
	@Value("${t_pro_tec_info}")
	private String t_pro_tec_info;
	// 技能等级信息
	@Value("${t_skill_level_info}")
	private String t_skill_level_info;
	// 专家人才称号
	@Value("${t_expert_title_info}")
	private String t_expert_title_info;
	// 学术成果
	@Value("${t_acade_achive_info}")
	private String t_acade_achive_info;
	// 制度标准
	@Value("${t_stand_info}")
	private String t_stand_info;
	// 专利信息
	@Value("${t_patent_info}")
	private String t_patent_info;
	// 技艺革新信息
	@Value("${t_tec_innov_info}")
	private String t_tec_innov_info;
	// 竞赛考试信息
	@Value("${t_contest_info}")
	private String t_contest_info;
	// 科技管理及创新成果
	@Value("${t_tec_man_innov}")
	private String t_tec_man_innov;
	// 个人荣誉
	@Value("${t_honor_info}")
	private String t_honor_info;
	// 项目课题成果
	@Value("${t_proj_achieve_info}")
	private String t_proj_achieve_info;
	// 导师带徒
	@Value("${t_sdt_tutor_prent_info}")
	private String t_sdt_tutor_prent_info;
	// 工作经历
	@Value("${t_work_exp_info}")
	private String t_work_exp_info;
	// 挂职轮岗
	@Value("${t_rotation_info}")
	private String t_rotation_info;
	// 员工流动
	@Value("${t_employee_mobility}")
	private String t_employee_mobility;
	// 技术标准
	@Value("${t_tec_standard_info}")
	private String t_tec_standard_info;

	/**
	 * 基本信息添加和编辑
	 *
	 * @param baseInfo
	 * @param user
	 */
	@Override
	@Transactional
	public String addBaseInfo(TEmpBaseInfo baseInfo, User user) throws Exception {
		baseInfo.setUpdaterId(user.getFax());
		baseInfo.setUpdaterName(user.getName());
		if (baseInfo.getIsAdd().equals("0")) {// 新增
			baseInfo.setCreaterId(user.getFax());
			baseInfo.setCreaterName(user.getName());
			baseInfo.setOrignalId(baseInfo.getId());
			baseInfo.setPrimitiveId(baseInfo.getId());
			baseInfo.setBusinessTypeId(t_emp_base_info);
			baseInfo.setDelSign(0);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				baseInfo.setIsValid(0);
				baseInfo.setFlowStatus(1);// 不要审批，默认通过
			} else {
				baseInfo.setIsValid(1);
				baseInfo.setFlowStatus(0);// 要审批
				/*
				 * //先删除之前的审批流程 //updateWorkFlowDataByPrimitiveId(baseInfo.getPrimitiveId());
				 * addWorkFlowData(baseInfo.getId(),baseInfo.getPrimitiveId(),baseInfo.
				 * getAuditErpNo(),t_emp_base_info,user.getFax(),dealRoleCode);
				 */
			}
			userInfoDao.addBaseInfo(baseInfo);
			// 新增插入操作记录
			addRecordLogData(baseInfo.getId(), user, "0");
		} else {// 修改
				// 日志记录--获取原始业务数据
			TEmpBaseInfo oldTEmpBaseInfo = userInfoDao.getBaseInfoById(baseInfo.getOrignalId());
			// 管理员和普通用户修改手机号码都不走流程
			workFlowService.updateBaseInfoYes(baseInfo);
			// 修改插入操作记录
//			addRecordLogData(baseInfo.getPrimitiveId(),user,"2");
			// 日志记录
			addRecordLogInfo(baseInfo, oldTEmpBaseInfo, user, baseInfo.getPrimitiveId(), baseInfo.getId(), "2");
		}
		return null;
	}

	@Override
	public TEmpBaseInfo getBaseInfoById(String id) {
		return userInfoDao.getBaseInfoById(id);
	}

	@Override
	public TEmpBaseInfo getBaseInfoByErpNo(String erpNo) {
		return userInfoDao.getBaseInfoByErpNo(erpNo);
	}

	/**
	 * 年度绩效
	 *
	 * @param yearEffectInfo
	 * @param user
	 * @throws Exception
	 */
	@Override
	@Transactional
	public String addYearEffect(TYearEffectInfo yearEffectInfo, User user) throws Exception {
		yearEffectInfo.setUpdaterId(user.getFax());
		yearEffectInfo.setUpdaterName(user.getName());
		if (yearEffectInfo.getIsAdd().equals("0")) {// 新增
			yearEffectInfo.setCreaterId(user.getFax());
			yearEffectInfo.setOrgId(user.getBaseOrgId());// 单位ID
			yearEffectInfo.setCreaterName(user.getName());
			yearEffectInfo.setOrignalId(yearEffectInfo.getId());
			yearEffectInfo.setPrimitiveId(yearEffectInfo.getId());
			yearEffectInfo.setBusinessTypeId(t_year_effect_info);
			yearEffectInfo.setDelSign(0);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				yearEffectInfo.setIsValid(0);
				yearEffectInfo.setFlowStatus(1);// 不要审批，默认通过
			} else {
				yearEffectInfo.setIsValid(1);
				yearEffectInfo.setFlowStatus(0);// 要审批

				// 添加流程-add by yangwang 20200803
				/*
				 * //先删除之前的审批流程
				 * //updateWorkFlowDataByPrimitiveId(yearEffectInfo.getPrimitiveId());
				 * addWorkFlowData(yearEffectInfo.getId(),yearEffectInfo.getPrimitiveId(),
				 * yearEffectInfo.getAuditErpNo(),t_year_effect_info,user.getFax(),dealRoleCode)
				 * ;
				 */
//				workFlowAntService.addWorkFlow(user, t_year_effect_info, yearEffectInfo.getId(), null, null);
			}
			userInfoDao.addYearEffect(yearEffectInfo);
			// 新增插入操作记录
			addRecordLogData(yearEffectInfo.getId(), user, "0");
			// 删除草稿箱数据
			draftsService.deleteMes(yearEffectInfo.getId(), "t_year_effect_info_drafts");
			// 删除草稿箱列表数据
			draftsService.deleteDraftsListByBusinessId(yearEffectInfo.getId());
			if (!(("2").equals(user.getRemark()) || ("3").equals(user.getRemark()))) {// 非管理员
				workFlowAntService.addWorkFlow(user, t_year_effect_info, yearEffectInfo.getId(), null, null);
			}
		} else {// 修改
			//待审核可编辑-xyy
			/*if ("1".equals(yearEffectInfo.getIsAdd())) {
				List<TYearEffectInfo> yearEffectInfos = getReadyYearEffectById(yearEffectInfo.getId());
				if (yearEffectInfos != null && yearEffectInfos.size() > 0) {
					return "当前数据已经存在待审核状态";
				}
			}*/
			yearEffectInfo.setBusinessTypeId(t_year_effect_info);// 防止数据直接从数据库维护进去，business_type_id为空，再次编辑的时候还是为空
			// 日志记录--获取原始业务数据
			String orignalId = "";
			if (!(StringUtil.isNullOrEmpty(yearEffectInfo.getProgressCheckId()))) {// 如果是进度查看里的编辑
				orignalId = yearEffectInfo.getProgressCheckId();
			} else {
				orignalId = yearEffectInfo.getOrignalId();
			}
			TYearEffectInfo oldTYearEffectInfo = userInfoDao.getYearEffectById(orignalId);
			//待审核编辑不新增流程-xyy
			List<TYearEffectInfo> yearEffectInfos = getReadyYearEffectById(yearEffectInfo.getOrignalId());
			if ("1".equals(yearEffectInfo.getIsAdd()) && yearEffectInfos != null && yearEffectInfos.size() > 0) {
				yearEffectInfo.setId(yearEffectInfo.getOrignalId());
				workFlowService.updateYearEffect(yearEffectInfo, user);
			}else {
				if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员添加的不用插入到审批表
					yearEffectInfo.setFlowStatus(1);
					workFlowService.updateYearEffect(yearEffectInfo, user);
				} else {// 普通用户
					yearEffectInfo.setIsValid(1);
					yearEffectInfo.setFlowStatus(0);// 要审批
					yearEffectInfo.setCreaterId(user.getFax());
					yearEffectInfo.setCreaterName(user.getName());
					yearEffectInfo.setOrgId(user.getBaseOrgId());
//				yearEffectInfo.setOrignalId(yearEffectInfo.getId());
//				yearEffectInfo.setId(IdGen.uuid());
					userInfoDao.addYearEffect(yearEffectInfo);
					// 添加流程-add by yangwang 20200803
					/*
					 * //先删除之前的审批流程
					 * updateWorkFlowDataByPrimitiveId(yearEffectInfo.getPrimitiveId());
					 * addWorkFlowData(yearEffectInfo.getId(),yearEffectInfo.getPrimitiveId(),
					 * yearEffectInfo.getAuditErpNo(),t_year_effect_info,user.getFax(),dealRoleCode)
					 * ;
					 */
					workFlowAntService.addWorkFlow(user, t_year_effect_info, yearEffectInfo.getId(), null, null);
				}
			}


			// 修改插入操作记录
//			addRecordLogData(yearEffectInfo.getPrimitiveId(),user,"2");
			oldTYearEffectInfo.setPerforGrade(SysDictionaryUtil.getNameByValueForDefault("PerformLevelRecentThreeYears",
					oldTYearEffectInfo.getPerforGrade()));// 绩效等级
			yearEffectInfo.setPerforGrade(SysDictionaryUtil.getNameByValueForDefault("PerformLevelRecentThreeYears",
					yearEffectInfo.getPerforGrade()));// 绩效等级
			addRecordLogInfo(yearEffectInfo, oldTYearEffectInfo, user, yearEffectInfo.getPrimitiveId(),
					yearEffectInfo.getId(), "2");
		}
		return null;
	}

	@Override
	public TYearEffectInfo getYearEffectById(String id) {
		return userInfoDao.getYearEffectById(id);
	}

	public List<TYearEffectInfo> getYearEffectByErpNo(String erpNo) {
		return userInfoDao.getYearEffectByErpNo(erpNo);
	}

	@Override
	public void findPageYearEffectByCondi(Page<TYearEffectInfo> page, TYearEffectInfo tYearEffectInfo) {
		userInfoDao.findPageYearEffectByCondi(page, tYearEffectInfo);
	}

	/**
	 * 学历信息
	 *
	 * @param tEducateInfo
	 * @param user
	 * @throws Exception
	 */
	@Override
	@Transactional
	public String addEducateInfo(TEducateInfo tEducateInfo, User user) throws Exception {
		tEducateInfo.setUpdaterId(user.getFax());
		tEducateInfo.setUpdaterName(user.getName());
		if (tEducateInfo.getIsAdd().equals("0")) {// 新增
			tEducateInfo.setCreaterId(user.getFax());
			tEducateInfo.setCreaterName(user.getName());
			tEducateInfo.setOrgId(user.getBaseOrgId());// 单位ID
			tEducateInfo.setOrignalId(tEducateInfo.getId());
			tEducateInfo.setPrimitiveId(tEducateInfo.getId());
			tEducateInfo.setBusinessTypeId(t_educate_info);
			tEducateInfo.setDelSign(0);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				tEducateInfo.setIsValid(0);
				tEducateInfo.setFlowStatus(1);// 不要审批，默认通过
			} else {
				tEducateInfo.setIsValid(1);
				tEducateInfo.setFlowStatus(0);// 要审批

				// 添加流程-add by yangwang 20200803
				/*
				 * //先删除之前的审批流程
				 * //updateWorkFlowDataByPrimitiveId(tEducateInfo.getPrimitiveId());
				 * addWorkFlowData(tEducateInfo.getId(),tEducateInfo.getPrimitiveId(),
				 * tEducateInfo.getAuditErpNo(),t_educate_info,user.getFax(),dealRoleCode);
				 */
//				workFlowAntService.addWorkFlow(user, t_educate_info, tEducateInfo.getId(), null, null);
			}
			//彭孟志20210611修改，如果是最高学历，当前人其他学历就不能是最高学历
			if("0".equals(tEducateInfo.getIsHighestEduc())){
				userInfoDao.updateEducateInfo(tEducateInfo);
			}

			userInfoDao.addEducateInfo(tEducateInfo);

			// 新增插入操作记录
			addRecordLogData(tEducateInfo.getId(), user, "0");
			// 删除草稿箱数据
			draftsService.deleteMes(tEducateInfo.getId(), "t_educate_info_drafts");
			// 删除草稿箱列表数据
			draftsService.deleteDraftsListByBusinessId(tEducateInfo.getId());
			if (!(("2").equals(user.getRemark()) || ("3").equals(user.getRemark()))) {// 非管理员
				workFlowAntService.addWorkFlow(user, t_educate_info, tEducateInfo.getId(), null, null);
			}
		} else {// 修改
			List<TSalaryBusinessBind> list = userInfoDao.selectSalaryBusinessBind(t_educate_info,tEducateInfo.getOrignalId());
			if(!CollectionUtils.isEmpty(list)){
				return "当前数据已用于薪档申报，不可修改！";
			}
			//待审核可编辑-xyy
			/*if ("1".equals(tEducateInfo.getIsAdd())) {
				List<TEducateInfo> tEducateInfos = getReadyEducateInfoById(tEducateInfo.getId());
				if (tEducateInfos != null && tEducateInfos.size() > 0) {
					return "当前数据已经存在待审核状态";
				}
			}*/
			tEducateInfo.setBusinessTypeId(t_educate_info);// 防止数据直接从数据库维护进去，business_type_id为空，再次编辑的时候还是为空
			// 日志记录--获取原始业务数据
			String orignalId = "";
			if (!(StringUtil.isNullOrEmpty(tEducateInfo.getProgressCheckId()))) {// 如果是进度查看里的编辑
				orignalId = tEducateInfo.getProgressCheckId();
			} else {
				orignalId = tEducateInfo.getOrignalId();
			}
			TEducateInfo oldTEducateInfo = userInfoDao.getEducateInfoById(orignalId);
			//待审核编辑不新增流程-xyy
			List<TEducateInfo> tEducateInfos = getReadyEducateInfoById(tEducateInfo.getOrignalId());
			if ("1".equals(tEducateInfo.getIsAdd()) && tEducateInfos != null && tEducateInfos.size() > 0) {
				tEducateInfo.setId(tEducateInfo.getOrignalId());
				workFlowService.updateEducateInfoYes(tEducateInfo, user);
			}else{
				if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
					tEducateInfo.setFlowStatus(1);
					workFlowService.updateEducateInfoYes(tEducateInfo, user);
				} else {// 普通用户
					tEducateInfo.setIsValid(1);
					tEducateInfo.setFlowStatus(0);// 要审批
					tEducateInfo.setCreaterId(user.getFax());
					tEducateInfo.setCreaterName(user.getName());
					tEducateInfo.setOrgId(user.getBaseOrgId());
//				tEducateInfo.setOrignalId(tEducateInfo.getId());
//				tEducateInfo.setId(IdGen.uuid());
					userInfoDao.addEducateInfo(tEducateInfo);

					// 添加流程-add by yangwang 20200803
					/*
					 * //先删除之前的审批流程 updateWorkFlowDataByPrimitiveId(tEducateInfo.getPrimitiveId());
					 * addWorkFlowData(tEducateInfo.getId(),tEducateInfo.getPrimitiveId(),
					 * tEducateInfo.getAuditErpNo(),t_educate_info,user.getFax(),dealRoleCode);
					 */
					workFlowAntService.addWorkFlow(user, t_educate_info, tEducateInfo.getId(), null, null);
				}
			}

			// 修改插入操作记录
//			addRecordLogData(tEducateInfo.getPrimitiveId(),user,"2");
			// 日志记录
			oldTEducateInfo.setSchoolType(
					SysDictionaryUtil.getNameByValueForDefault("CollegeCategory", oldTEducateInfo.getSchoolType()));// 院校类别
			oldTEducateInfo.setEducName(SysDictionaryUtil.getNameByValueForDefault("PersonnelQualifications",
					oldTEducateInfo.getEducName()));// 学历名称
			oldTEducateInfo.setDegreeName(
					SysDictionaryUtil.getNameByValueForDefault("AcademicDegree", oldTEducateInfo.getDegreeName()));// 学位名称
			if (("0").equals(oldTEducateInfo.getIsContEduc())) {
				oldTEducateInfo.setIsContEduc("是");
			} else {
				oldTEducateInfo.setIsContEduc("否");
			} // 是否全日制
			if (("0").equals(oldTEducateInfo.getIsEmployEduc())) {
				oldTEducateInfo.setIsEmployEduc("是");
			} else {
				oldTEducateInfo.setIsEmployEduc("否");
			} // 是否就业学历
			if (("0").equals(oldTEducateInfo.getIsHighestEduc())) {
				oldTEducateInfo.setIsHighestEduc("是");
			} else {
				oldTEducateInfo.setIsHighestEduc("否");
			} // 是否最高学历
			tEducateInfo.setSchoolType(
					SysDictionaryUtil.getNameByValueForDefault("CollegeCategory", tEducateInfo.getSchoolType()));// 院校类别
			tEducateInfo.setEducName(
					SysDictionaryUtil.getNameByValueForDefault("PersonnelQualifications", tEducateInfo.getEducName()));// 学历名称
			tEducateInfo.setDegreeName(
					SysDictionaryUtil.getNameByValueForDefault("AcademicDegree", tEducateInfo.getDegreeName()));// 学位名称
			if (("0").equals(tEducateInfo.getIsContEduc())) {
				tEducateInfo.setIsContEduc("是");
			} else {
				tEducateInfo.setIsContEduc("否");
			} // 是否全日制
			if (("0").equals(tEducateInfo.getIsEmployEduc())) {
				tEducateInfo.setIsEmployEduc("是");
			} else {
				tEducateInfo.setIsEmployEduc("否");
			}
			if (("0").equals(tEducateInfo.getIsHighestEduc())) {
				tEducateInfo.setIsHighestEduc("是");
			} else {
				tEducateInfo.setIsHighestEduc("否");
			}
			addRecordLogInfo(tEducateInfo, oldTEducateInfo, user, tEducateInfo.getPrimitiveId(), tEducateInfo.getId(),
					"2");
		}
		return null;
	}

	@Override
	public TEducateInfo getEducateInfoById(String id) {
		return userInfoDao.getEducateInfoById(id);
	}

	@Override
	public List<TEducateInfo> getEducateInfoByErpNo(String erpNo, String isCountEduc) {
		return userInfoDao.getEducateInfoByErpNo(erpNo, isCountEduc);
	}

	@Override
	public void findPageEducateInfoByCondi(Page<TEducateInfo> page, TEducateInfo tEducateInfo) {
		userInfoDao.findPageEducateInfoByCondi(page, tEducateInfo);
	}

	/**
	 * 专业技术资格
	 *
	 * @param tProTecInfo
	 * @param user
	 * @throws Exception
	 */
	@Override
	@Transactional
	public String addProTecInfo(TProTecInfo tProTecInfo, User user) throws Exception {
		tProTecInfo.setUpdaterId(user.getFax());
		tProTecInfo.setUpdaterName(user.getName());
		if (tProTecInfo.getIsAdd().equals("0")) {// 新增
			tProTecInfo.setCreaterId(user.getFax());
			tProTecInfo.setCreaterName(user.getName());
			tProTecInfo.setOrgId(user.getBaseOrgId());// 单位ID
			tProTecInfo.setOrignalId(tProTecInfo.getId());
			tProTecInfo.setPrimitiveId(tProTecInfo.getId());
			tProTecInfo.setBusinessTypeId(t_pro_tec_info);
			tProTecInfo.setDelSign(0);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				tProTecInfo.setIsValid(0);
				tProTecInfo.setFlowStatus(1);// 不要审批，默认通过
			} else {
				tProTecInfo.setIsValid(1);
				tProTecInfo.setFlowStatus(0);// 要审批

				// 添加流程-add by yangwang 20200803
				/*
				 * //先删除之前的审批流程 //updateWorkFlowDataByPrimitiveId(tProTecInfo.getPrimitiveId());
				 * addWorkFlowData(tProTecInfo.getId(),tProTecInfo.getPrimitiveId(),tProTecInfo.
				 * getAuditErpNo(),t_pro_tec_info,user.getFax(),dealRoleCode);
				 */
//				workFlowAntService.addWorkFlow(user, t_pro_tec_info, tProTecInfo.getId(), null, null);
			}
			userInfoDao.addProTecInfo(tProTecInfo);
			// 新增插入操作记录
			addRecordLogData(tProTecInfo.getId(), user, "0");
			// 删除草稿箱数据
			draftsService.deleteMes(tProTecInfo.getId(), "t_pro_tec_info_drafts");
			// 删除草稿箱列表数据
			draftsService.deleteDraftsListByBusinessId(tProTecInfo.getId());
			if (!(("2").equals(user.getRemark()) || ("3").equals(user.getRemark()))) {// 非管理员
				workFlowAntService.addWorkFlow(user, t_pro_tec_info, tProTecInfo.getId(), null, null);
			}
		} else {// 修改
			List<TSalaryBusinessBind> list = userInfoDao.selectSalaryBusinessBind(t_pro_tec_info,tProTecInfo.getOrignalId());
			if(!CollectionUtils.isEmpty(list)){
				return "当前数据已用于薪档申报，不可修改！";
			}
			//待审核可编辑-xyy
			/*if ("1".equals(tProTecInfo.getIsAdd())) {
				List<TProTecInfo> tProTecInfos = getReadyProTecInfoById(tProTecInfo.getId());
				if (tProTecInfos != null && tProTecInfos.size() > 0) {
					return "当前数据已经存在待审核状态";
				}
			}*/
			// 防止数据直接从数据库维护进去，business_type_id为空，再次编辑的时候还是为空
			tProTecInfo.setBusinessTypeId(t_pro_tec_info);
			// 日志记录--获取原始业务数据
			String orignalId = "";
			if (!(StringUtil.isNullOrEmpty(tProTecInfo.getProgressCheckId()))) {// 如果是进度查看里的编辑
				orignalId = tProTecInfo.getProgressCheckId();
			} else {
				orignalId = tProTecInfo.getOrignalId();
			}
			TProTecInfo oldTProTecInfo = userInfoDao.getProTecInfoById(orignalId);
			//待审核编辑不新增流程-xyy
			List<TProTecInfo> tProTecInfos = getReadyProTecInfoById(tProTecInfo.getOrignalId());
			if ("1".equals(tProTecInfo.getIsAdd()) && tProTecInfos != null && tProTecInfos.size() > 0) {
				tProTecInfo.setId(tProTecInfo.getOrignalId());
				workFlowProcessService.updateTProTecInfo(tProTecInfo, user);
			}else{
				if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
					tProTecInfo.setFlowStatus(1);
					workFlowProcessService.updateTProTecInfo(tProTecInfo, user);
				} else {// 普通用户
					tProTecInfo.setIsValid(1);
					tProTecInfo.setCreaterId(user.getFax());
					tProTecInfo.setCreaterName(user.getName());
					tProTecInfo.setOrgId(user.getBaseOrgId());
					tProTecInfo.setFlowStatus(0);// 要审批
//				tProTecInfo.setOrignalId(tProTecInfo.getId());
//				tProTecInfo.setId(IdGen.uuid());
					userInfoDao.addProTecInfo(tProTecInfo);

					// 添加流程-add by yangwang 20200803
					/*
					 * //先删除之前的审批流程 updateWorkFlowDataByPrimitiveId(tProTecInfo.getPrimitiveId());
					 * addWorkFlowData(tProTecInfo.getId(),tProTecInfo.getPrimitiveId(),tProTecInfo.
					 * getAuditErpNo(),t_pro_tec_info,user.getFax(),dealRoleCode);
					 */
					workFlowAntService.addWorkFlow(user, t_pro_tec_info, tProTecInfo.getId(), null, null);
				}
			}

			// 修改插入操作记录
//			addRecordLogData(tProTecInfo.getPrimitiveId(),user,"2");
			oldTProTecInfo.setSubjSet(SysDictionaryUtil.getNameByValueForDefault("ProTechnicalQualifications",
					oldTProTecInfo.getSubjSet()));// 专业技术资格系列
			oldTProTecInfo.setSubjLevel(SysDictionaryUtil.getNameByValueForDefault("ProfessionalQualifications",
					oldTProTecInfo.getSubjLevel()));// 专业技术资格等级
			oldTProTecInfo.setOrgLevel(SysDictionaryUtil.getNameByValueForDefault("IdentificationUnitLevel",
					oldTProTecInfo.getOrgLevel()));// 发证单位级别
			tProTecInfo.setSubjSet(
					SysDictionaryUtil.getNameByValueForDefault("ProTechnicalQualifications", tProTecInfo.getSubjSet()));// 专业技术资格系列
			tProTecInfo.setSubjLevel(SysDictionaryUtil.getNameByValueForDefault("ProfessionalQualifications",
					tProTecInfo.getSubjLevel()));// 专业技术资格等级
			tProTecInfo.setOrgLevel(
					SysDictionaryUtil.getNameByValueForDefault("IdentificationUnitLevel", tProTecInfo.getOrgLevel()));// 发证单位级别
			addRecordLogInfo(tProTecInfo, oldTProTecInfo, user, tProTecInfo.getPrimitiveId(), tProTecInfo.getId(), "2");
		}
		return null;
	}

	@Override
	public TProTecInfo getProTecInfoById(String id) {
		return userInfoDao.getProTecInfoById(id);
	}

	@Override
	public List<TProTecInfo> getProTecInfoByErpNo(String erpNo) {
		return userInfoDao.getProTecInfoByErpNo(erpNo);
	}

	@Override
	public void findPageProTecInfoByCondi(Page<TProTecInfo> page, TProTecInfo tProTecInfo) {
		userInfoDao.findPageProTecInfoByCondi(page, tProTecInfo);
	}

	/**
	 * 技能等级
	 *
	 * @param tSkillLevelInfo
	 * @param user
	 * @throws Exception
	 */
	@Override
	@Transactional
	public String addSkillLevelInfo(TSkillLevelInfo tSkillLevelInfo, User user) throws Exception {
		tSkillLevelInfo.setUpdaterId(user.getFax());
		tSkillLevelInfo.setUpdaterName(user.getName());
		if (tSkillLevelInfo.getIsAdd().equals("0")) {// 新增
			tSkillLevelInfo.setCreaterId(user.getFax());
			tSkillLevelInfo.setCreaterName(user.getName());
			tSkillLevelInfo.setOrgId(user.getBaseOrgId());// 单位ID
			tSkillLevelInfo.setOrignalId(tSkillLevelInfo.getId());
			tSkillLevelInfo.setPrimitiveId(tSkillLevelInfo.getId());
			tSkillLevelInfo.setBusinessTypeId(t_skill_level_info);
			tSkillLevelInfo.setDelSign(0);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				tSkillLevelInfo.setIsValid(0);
				tSkillLevelInfo.setFlowStatus(1);// 不要审批，默认通过
			} else {
				tSkillLevelInfo.setIsValid(1);
				tSkillLevelInfo.setFlowStatus(0);// 要审批

				// 添加流程-add by yangwang 20200803
				/*
				 * //先删除之前的审批流程
				 * //updateWorkFlowDataByPrimitiveId(tSkillLevelInfo.getPrimitiveId());
				 * addWorkFlowData(tSkillLevelInfo.getId(),tSkillLevelInfo.getPrimitiveId(),
				 * tSkillLevelInfo.getAuditErpNo(),t_skill_level_info,user.getFax(),
				 * dealRoleCode)
				 */;
//				workFlowAntService.addWorkFlow(user, t_skill_level_info, tSkillLevelInfo.getId(), null, null);
			}
			userInfoDao.addSkillLevelInfo(tSkillLevelInfo);
			// 新增插入操作记录
			addRecordLogData(tSkillLevelInfo.getId(), user, "0");
			// 删除草稿箱数据
			draftsService.deleteMes(tSkillLevelInfo.getId(), "t_skill_level_info_drafts");
			// 删除草稿箱列表数据
			draftsService.deleteDraftsListByBusinessId(tSkillLevelInfo.getId());
			// 插入工作流
			if (!(("2").equals(user.getRemark()) || ("3").equals(user.getRemark()))) {// 非管理员
				workFlowAntService.addWorkFlow(user, t_skill_level_info, tSkillLevelInfo.getId(), null, null);
			}
		} else {// 修改
			List<TSalaryBusinessBind> list = userInfoDao.selectSalaryBusinessBind(t_skill_level_info,tSkillLevelInfo.getOrignalId());
			if(!CollectionUtils.isEmpty(list)){
				return "当前数据已用于薪档申报，不可修改！";
			}
			//待审核可编辑-xyy
			/*if ("1".equals(tSkillLevelInfo.getIsAdd())) {
				List<TSkillLevelInfo> tSkillLevelInfos = getReadySkillLevelInfoById(tSkillLevelInfo.getId());
				if (tSkillLevelInfos != null && tSkillLevelInfos.size() > 0) {
					return "当前数据已经存在待审核状态";
				}
			}*/
			// 防止数据直接从数据库维护进去，business_type_id为空，再次编辑的时候还是为空
			tSkillLevelInfo.setBusinessTypeId(t_skill_level_info);
			// 日志记录--获取原始业务数据
			String orignalId = "";
			if (!(StringUtil.isNullOrEmpty(tSkillLevelInfo.getProgressCheckId()))) {// 如果是进度查看里的编辑
				orignalId = tSkillLevelInfo.getProgressCheckId();
			} else {
				orignalId = tSkillLevelInfo.getOrignalId();
			}
			TSkillLevelInfo oldTSkillLevelInfo = userInfoDao.getTSkillLevelInfoById(orignalId);
			//待审核编辑不新增流程-xyy
			List<TSkillLevelInfo> tSkillLevelInfos = getReadySkillLevelInfoById(tSkillLevelInfo.getOrignalId());
			if ("1".equals(tSkillLevelInfo.getIsAdd()) && tSkillLevelInfos != null && tSkillLevelInfos.size() > 0) {
				tSkillLevelInfo.setId(tSkillLevelInfo.getOrignalId());
				workFlowProcessService.updateTSkillLevelInfo(tSkillLevelInfo, user);
			}else{
				if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
					tSkillLevelInfo.setFlowStatus(1);
					workFlowProcessService.updateTSkillLevelInfo(tSkillLevelInfo, user);
				} else {// 普通用户
					tSkillLevelInfo.setIsValid(1);
					tSkillLevelInfo.setCreaterId(user.getFax());
					tSkillLevelInfo.setCreaterName(user.getName());
					tSkillLevelInfo.setOrgId(user.getBaseOrgId());
					tSkillLevelInfo.setFlowStatus(0);// 要审批
//				tSkillLevelInfo.setOrignalId(tSkillLevelInfo.getId());
//				tSkillLevelInfo.setId(IdGen.uuid());
					userInfoDao.addSkillLevelInfo(tSkillLevelInfo);

					// 添加流程-add by yangwang 20200803
					/*
					 * //先删除之前的审批流程
					 * updateWorkFlowDataByPrimitiveId(tSkillLevelInfo.getPrimitiveId());
					 * addWorkFlowData(tSkillLevelInfo.getId(),tSkillLevelInfo.getPrimitiveId(),
					 * tSkillLevelInfo.getAuditErpNo(),t_skill_level_info,user.getFax(),dealRoleCode
					 * );
					 */
					workFlowAntService.addWorkFlow(user, t_skill_level_info, tSkillLevelInfo.getId(), null, null);
				}
			}

			// 修改插入操作记录
//			addRecordLogData(tSkillLevelInfo.getPrimitiveId(),user,"2");
			oldTSkillLevelInfo.setTechType(
					SysDictionaryUtil.getNameByValueForDefault("SkillAppraisalWork", oldTSkillLevelInfo.getTechType()));// 技能鉴定工种
			oldTSkillLevelInfo.setQualifiLevel(SysDictionaryUtil.getNameByValueForDefault("QualificationLevel",
					oldTSkillLevelInfo.getQualifiLevel()));// 职业资格等级
			oldTSkillLevelInfo.setOrgLevel(SysDictionaryUtil.getNameByValueForDefault("IdentificationUnitLevel",
					oldTSkillLevelInfo.getOrgLevel()));// 发证单位级别
			tSkillLevelInfo.setTechType(
					SysDictionaryUtil.getNameByValueForDefault("SkillAppraisalWork", tSkillLevelInfo.getTechType()));// 技能鉴定工种
			tSkillLevelInfo.setQualifiLevel(SysDictionaryUtil.getNameByValueForDefault("QualificationLevel",
					tSkillLevelInfo.getQualifiLevel()));// 职业资格等级
			tSkillLevelInfo.setOrgLevel(SysDictionaryUtil.getNameByValueForDefault("IdentificationUnitLevel",
					tSkillLevelInfo.getOrgLevel()));// 发证单位级别
			addRecordLogInfo(tSkillLevelInfo, oldTSkillLevelInfo, user, tSkillLevelInfo.getPrimitiveId(),
					tSkillLevelInfo.getId(), "2");
		}
		return null;
	}

	@Override
	public TSkillLevelInfo getSkillLevelInfoById(String id) {
		return userInfoDao.getTSkillLevelInfoById(id);
	}

	@Override
	public List<TSkillLevelInfo> getSkillLevelInfoByErpNo(String erpNo) {
		return userInfoDao.getSkillLevelInfoByErpNo(erpNo);
	}

	@Override
	public void findPageSkillLevelInfoByCondi(Page<TSkillLevelInfo> page, TSkillLevelInfo tSkillLevelInfo) {
		userInfoDao.findPageSkillLevelInfoByCondi(page, tSkillLevelInfo);
	}

	/**
	 * 专家人才称号
	 *
	 * @param tExpertTitleInfo
	 * @param user
	 * @throws Exception
	 */
	@Override
	@Transactional
	public String addExpertTitleInfo(TExpertTitleInfo tExpertTitleInfo, User user) throws Exception {
		tExpertTitleInfo.setUpdaterId(user.getFax());
		tExpertTitleInfo.setUpdaterName(user.getName());
		if (tExpertTitleInfo.getIsAdd().equals("0")) {// 新增
			tExpertTitleInfo.setCreaterId(user.getFax());
			tExpertTitleInfo.setCreaterName(user.getName());
			tExpertTitleInfo.setOrgId(user.getBaseOrgId());// 单位ID
			tExpertTitleInfo.setOrignalId(tExpertTitleInfo.getId());
			tExpertTitleInfo.setPrimitiveId(tExpertTitleInfo.getId());
			tExpertTitleInfo.setBusinessTypeId(t_expert_title_info);
			tExpertTitleInfo.setDelSign(0);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				tExpertTitleInfo.setIsValid(0);
				tExpertTitleInfo.setFlowStatus(1);// 不要审批，默认通过
			} else {
				tExpertTitleInfo.setIsValid(1);
				tExpertTitleInfo.setFlowStatus(0);// 要审批

				// 添加流程-add by yangwang 20200803
				/*
				 * //先删除之前的审批流程
				 * //updateWorkFlowDataByPrimitiveId(tExpertTitleInfo.getPrimitiveId());
				 * addWorkFlowData(tExpertTitleInfo.getId(),tExpertTitleInfo.getPrimitiveId(),
				 * tExpertTitleInfo.getAuditErpNo(),t_expert_title_info,user.getFax(),
				 * dealRoleCode);
				 */
//				workFlowAntService.addWorkFlow(user, t_expert_title_info, tExpertTitleInfo.getId(), null, null);
			}
			userInfoDao.addExpertTitleInfo(tExpertTitleInfo);
			// 新增插入操作记录
			addRecordLogData(tExpertTitleInfo.getId(), user, "0");
			// 删除草稿箱数据
			draftsService.deleteMes(tExpertTitleInfo.getId(), "t_expert_title_info_drafts");
			// 删除草稿箱列表数据
			draftsService.deleteDraftsListByBusinessId(tExpertTitleInfo.getId());
			// 插入工作流
			if (!(("2").equals(user.getRemark()) || ("3").equals(user.getRemark()))) {// 非管理员
				workFlowAntService.addWorkFlow(user, t_expert_title_info, tExpertTitleInfo.getId(), null, null);
			}
		} else {// 修改
			List<TSalaryBusinessBind> list = userInfoDao.selectSalaryBusinessBind(t_expert_title_info,tExpertTitleInfo.getOrignalId());
			if(!CollectionUtils.isEmpty(list)){
				return "当前数据已用于薪档申报，不可修改！";
			}
			//待审核可编辑-xyy
			/*if ("1".equals(tExpertTitleInfo.getIsAdd())) {
				List<TExpertTitleInfo> tExpertTitleInfos = getReadyExpertTitleInfoById(tExpertTitleInfo.getId());
				if (tExpertTitleInfos != null && tExpertTitleInfos.size() > 0) {
					return "当前数据已经存在待审核状态";
				}
			}*/
			// 防止数据直接从数据库维护进去，business_type_id为空，再次编辑的时候还是为空
			tExpertTitleInfo.setBusinessTypeId(t_expert_title_info);
			// 日志记录--获取原始业务数据
			String orignalId = "";
			if (!(StringUtil.isNullOrEmpty(tExpertTitleInfo.getProgressCheckId()))) {// 如果是进度查看里的编辑
				orignalId = tExpertTitleInfo.getProgressCheckId();
			} else {
				orignalId = tExpertTitleInfo.getOrignalId();
			}
			TExpertTitleInfo oldTExpertTitleInfo = userInfoDao.getExpertTitleInfoById(orignalId);
			//待审核编辑不新增流程-xyy
			List<TExpertTitleInfo> tExpertTitleInfos = getReadyExpertTitleInfoById(tExpertTitleInfo.getOrignalId());
			if ("1".equals(tExpertTitleInfo.getIsAdd()) && tExpertTitleInfos != null && tExpertTitleInfos.size() > 0) {
				tExpertTitleInfo.setId(tExpertTitleInfo.getOrignalId());
				workFlowProcessService.updateTExpertTitleInfo(tExpertTitleInfo, user);
			}else{
				if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
					tExpertTitleInfo.setFlowStatus(1);
					workFlowProcessService.updateTExpertTitleInfo(tExpertTitleInfo, user);
				} else {// 普通用户
					tExpertTitleInfo.setIsValid(1);
					tExpertTitleInfo.setCreaterId(user.getFax());
					tExpertTitleInfo.setCreaterName(user.getName());
					tExpertTitleInfo.setOrgId(user.getBaseOrgId());
					tExpertTitleInfo.setFlowStatus(0);// 要审批
//				tExpertTitleInfo.setOrignalId(tExpertTitleInfo.getId());
//				tExpertTitleInfo.setId(IdGen.uuid());
					userInfoDao.addExpertTitleInfo(tExpertTitleInfo);

					// 添加流程-add by yangwang 20200803
					/*
					 * //先删除之前的审批流程
					 * updateWorkFlowDataByPrimitiveId(tExpertTitleInfo.getPrimitiveId());
					 * addWorkFlowData(tExpertTitleInfo.getId(),tExpertTitleInfo.getPrimitiveId(),
					 * tExpertTitleInfo.getAuditErpNo(),t_expert_title_info,user.getFax(),
					 * dealRoleCode);
					 */
					workFlowAntService.addWorkFlow(user, t_expert_title_info, tExpertTitleInfo.getId(), null, null);
				}
			}

			// 修改插入操作记录
//			addRecordLogData(tExpertTitleInfo.getPrimitiveId(),user,"2");
			oldTExpertTitleInfo.setLevelName(
					SysDictionaryUtil.getNameByValueForDefault("ExpertLevel", oldTExpertTitleInfo.getLevelName()));// 等级
			oldTExpertTitleInfo.setType(
					SysDictionaryUtil.getNameByValueForDefault("ExpertCategory", oldTExpertTitleInfo.getType()));// 类别
			oldTExpertTitleInfo.setMajor(
					SysDictionaryUtil.getNameByValueForDefault("ProWorkTypes", oldTExpertTitleInfo.getMajor()));// 专业
			oldTExpertTitleInfo.setEmpTitle(
					SysDictionaryUtil.getNameByValueForDefault("TalentTitle", oldTExpertTitleInfo.getEmpTitle()));// 专家人才称号
			tExpertTitleInfo.setLevelName(
					SysDictionaryUtil.getNameByValueForDefault("ExpertLevel", tExpertTitleInfo.getLevelName()));// 等级
			tExpertTitleInfo
					.setType(SysDictionaryUtil.getNameByValueForDefault("ExpertCategory", tExpertTitleInfo.getType()));// 类别
			tExpertTitleInfo
					.setMajor(SysDictionaryUtil.getNameByValueForDefault("ProWorkTypes", tExpertTitleInfo.getMajor()));// 专业
			tExpertTitleInfo.setEmpTitle(
					SysDictionaryUtil.getNameByValueForDefault("TalentTitle", tExpertTitleInfo.getEmpTitle()));// 专家人才称号
			addRecordLogInfo(tExpertTitleInfo, oldTExpertTitleInfo, user, tExpertTitleInfo.getPrimitiveId(),
					tExpertTitleInfo.getId(), "2");
		}
		return null;
	}

	@Override
	public TExpertTitleInfo getExpertTitleInfoById(String id) {
		return userInfoDao.getExpertTitleInfoById(id);
	}

	@Override
	public List<TExpertTitleInfo> getExpertTitleInfoByErpNo(String erpNo) {

		return userInfoDao.getExpertTitleInfoByErpNo(erpNo);
	}

	@Override
	public void findPageExpertTitleInfoByCondi(Page<TExpertTitleInfo> page, TExpertTitleInfo tExpertTitleInfo) {
		userInfoDao.findPageExpertTitleInfoByCondi(page, tExpertTitleInfo);
	}

	/**
	 * 学术成果
	 *
	 * @param tAcadeAchiveInfo
	 * @param user
	 */
	@Override
	@Transactional
	public String addAcadeAchiveInfo(TAcadeAchiveInfo tAcadeAchiveInfo, User user) throws Exception {

		if (!("0").equals(tAcadeAchiveInfo.getIsAdd())){
			List<TSalaryBusinessBind> list = userInfoDao.selectSalaryBusinessBind(t_acade_achive_info,tAcadeAchiveInfo.getOrignalId());
			if(!CollectionUtils.isEmpty(list)){
				return "当前数据已用于薪档申报，不可修改！";
			}
		}

		tAcadeAchiveInfo.setUpdaterId(user.getFax());
		tAcadeAchiveInfo.setUpdaterName(user.getName());
		List<TPartRank> rankList = tAcadeAchiveInfo.gettPartRankList();
		// 根据erp_no过滤重复选中的人
		List<TPartRank> ranks = rankList.stream()
				.collect(Collectors.collectingAndThen(
						Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(TPartRank::getErpNo))),
						ArrayList::new));
		if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
			// 管理员给自己新增的时候要判断参与人里面有没有自己，如果给别人添加的时候要判断有没有选中当前选择的人，如果没有就不允许添加
			boolean flag = judgeTPartRankIsContainCurrentUser(ranks, tAcadeAchiveInfo.getErpNo());
			if (!flag) {
				// 返回错误信息
				String message = "当前添加的参与人员中没有包含当前选中的人";
				return message;
			}
		} else {// 普通用户
				// 普通人员新增的时候要判断参与人里面有没有当前登录人，如果没有就不允许添加
			boolean flag = judgeTPartRankIsContainCurrentUser(ranks, user.getFax());
			if (!flag) {
				// 返回错误信息
				String message = "当前添加的参与人员中没有包含当前登录人自己";
				return message;
			}
		}
		// isAdd=0，表示新增，isAdd=1表示正常编辑，isAdd=2表示审核时编辑(但是审核时编辑未走当前方法，走的是WorkFlowController里面的接口方法);
		// isAdd=3表示在新增时输入论文名称，点击下拉框中匹配的一条数据进行回显，并进行编辑,目前仅支持对参与人进行新增
		// 此时如果该条数据是待审核的(即flow_status=0)，那么无论是管理员操作还是普通用户操作，状态不变，仍为待审核，做update操作，
		// 如果该条数据是被驳回的，即(flow_status=3)，那么无论是管理员操作还是普通用户操作，新增一条待审核数据，做add操作，
		// 如果该条数据是有效数据，即(flow_status=1,且is_valid=0)，那么对该条数据进行编辑时走正常流程，即管理员操作后仍是有效数据，做update操作，普通用户操作新增一条待审核数据，做add操作
		if (("3").equals(tAcadeAchiveInfo.getIsAdd())) {
			if (1 == tAcadeAchiveInfo.getFlowStatus() && 0 == tAcadeAchiveInfo.getIsValid()) {// 有效的数据
				tAcadeAchiveInfo.setIsAdd("1");// 走正常编辑流程
			} else {
				String recordId = "";
				if (3 == tAcadeAchiveInfo.getFlowStatus()) {// 被驳回的，不管是管理员或是普通人员操作，都做add操作，并插入工作流
					// 插入一条新的待审核数据
					tAcadeAchiveInfo.setFlowStatus(0);// 待审核
					tAcadeAchiveInfo.setIsValid(1);
					userInfoDao.addAcadeAchiveInfo(tAcadeAchiveInfo);
					// 参与人
					addPartRank(ranks, tAcadeAchiveInfo.getId(), "12");
					// 插入工作流
					workFlowAntService.addWorkFlow(user, t_acade_achive_info, tAcadeAchiveInfo.getId(), null, null);
					recordId = tAcadeAchiveInfo.getProgressCheckId();
				} else {
					// 待审核状态的数据状态不变，只能修改参与人
					updatePartRankData(tAcadeAchiveInfo.getId(), ranks, "12");
					recordId = tAcadeAchiveInfo.getId();
				}
				// 插入日志
				TAcadeAchiveInfo oldTAcadeAchiveInfo = getAcadeAchiveInfoByIdForRecord(recordId);
				List<TPartRank> tPartRanks = tAcadeAchiveInfo.gettPartRankList();
				if (tPartRanks.size() > 0) {
					for (TPartRank rank : tPartRanks) {
						rank.setRoleName(
								SysDictionaryUtil.getNameByValueForDefault("XueshuchengguoJs", rank.getRole()));
					}
				}
				addRecordLogInfo(tAcadeAchiveInfo, oldTAcadeAchiveInfo, user, tAcadeAchiveInfo.getPrimitiveId(),
						tAcadeAchiveInfo.getId(), "2");
			}
		}
		if (("0").equals(tAcadeAchiveInfo.getIsAdd())) {// 新增
			// 判断论文名称是否重复--查询对象：有效的、待审核的、被驳回的,不通过的除外
			List<TAcadeAchiveInfoVo> list = userInfoDao.getAcadeAchiveInfoByAcadName(tAcadeAchiveInfo.getAcadName(),
					user.getBaseOrgId());
			if (list != null && list.size() > 0) {
				return "该论文（专著）名称已存在，请在填写名称时选择下拉项进行编辑";
			}
			tAcadeAchiveInfo.setCreaterId(user.getFax());
			tAcadeAchiveInfo.setCreaterName(user.getName());
			tAcadeAchiveInfo.setOrgId(user.getBaseOrgId());// 单位ID
			tAcadeAchiveInfo.setOrignalId(tAcadeAchiveInfo.getId());
			tAcadeAchiveInfo.setPrimitiveId(tAcadeAchiveInfo.getId());
			tAcadeAchiveInfo.setBusinessTypeId(t_acade_achive_info);
			tAcadeAchiveInfo.setDelSign(0);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				tAcadeAchiveInfo.setIsValid(0);
				tAcadeAchiveInfo.setFlowStatus(1);// 不要审批，默认通过
			} else {
				tAcadeAchiveInfo.setIsValid(1);
				tAcadeAchiveInfo.setFlowStatus(0);// 要审批
			}
			userInfoDao.addAcadeAchiveInfo(tAcadeAchiveInfo);
			addPartRank(ranks, tAcadeAchiveInfo.getId(), "12");
			// 新增插入操作记录
			addRecordLogData(tAcadeAchiveInfo.getId(), user, "0");
			// 删除草稿箱数据
			draftsService.deleteMes(tAcadeAchiveInfo.getId(), "t_acade_achive_info_drafts");
			// 删除草稿箱列表数据
			draftsService.deleteDraftsListByBusinessId(tAcadeAchiveInfo.getId());
			// 插入工作流
			if (!(("2").equals(user.getRemark()) || ("3").equals(user.getRemark()))) {// 非管理员
				workFlowAntService.addWorkFlow(user, t_acade_achive_info, tAcadeAchiveInfo.getId(), null, null);
			}
		} else if (("1").equals(tAcadeAchiveInfo.getIsAdd()) || ("2").equals(tAcadeAchiveInfo.getIsAdd())) {
			//待审核可编辑-xyy
			/*if ("1".equals(tAcadeAchiveInfo.getIsAdd())) {
				List<TAcadeAchiveInfo> tAcadeAchiveInfos = getReadyAcadeAchiveInfoById(tAcadeAchiveInfo.getId());
				if (tAcadeAchiveInfos != null && tAcadeAchiveInfos.size() > 0) {
					return "当前数据已经存在待审核状态";
				}
			}*/
			// 防止数据直接从数据库维护进去，business_type_id为空，再次编辑的时候还是为空
			tAcadeAchiveInfo.setBusinessTypeId(t_acade_achive_info);
			// 日志记录--获取原始业务数据
			String orignalId = "";
			if (!(StringUtil.isNullOrEmpty(tAcadeAchiveInfo.getProgressCheckId()))) {// 如果是进度查看里的编辑
				orignalId = tAcadeAchiveInfo.getProgressCheckId();
			} else {
				orignalId = tAcadeAchiveInfo.getOrignalId();
			}
			TAcadeAchiveInfo oldTAcadeAchiveInfo = getAcadeAchiveInfoByIdForRecord(orignalId);
			//待审核编辑不新增流程-xyy
			List<TAcadeAchiveInfo> tAcadeAchiveInfos = getReadyAcadeAchiveInfoById(tAcadeAchiveInfo.getOrignalId());
			if ("1".equals(tAcadeAchiveInfo.getIsAdd()) && tAcadeAchiveInfos != null && tAcadeAchiveInfos.size() > 0) {
				tAcadeAchiveInfo.setId(tAcadeAchiveInfo.getOrignalId());
				workFlowProcessService.updateTAcadeAchiveInfo(tAcadeAchiveInfo, user);
				// 参与人员修改
				updatePartRankData(tAcadeAchiveInfo.getId(), ranks, "12");
			}else{
				if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
					tAcadeAchiveInfo.setFlowStatus(1);
					workFlowProcessService.updateTAcadeAchiveInfo(tAcadeAchiveInfo, user);
					// 参与人员修改
					updatePartRankData(tAcadeAchiveInfo.getId(), ranks, "12");
				} else {// 普通用户
					tAcadeAchiveInfo.setIsValid(1);
					tAcadeAchiveInfo.setCreaterId(user.getFax());
					tAcadeAchiveInfo.setCreaterName(user.getName());
					tAcadeAchiveInfo.setOrgId(user.getBaseOrgId());
					tAcadeAchiveInfo.setFlowStatus(0);// 要审批
					addPartRank(ranks, tAcadeAchiveInfo.getId(), "12");
					userInfoDao.addAcadeAchiveInfo(tAcadeAchiveInfo);
					// 添加流程-add by yangwang 20200803
					workFlowAntService.addWorkFlow(user, t_acade_achive_info, tAcadeAchiveInfo.getId(), null, null);
				}
			}

			// 修改插入操作记录
			oldTAcadeAchiveInfo.setLevel(
					SysDictionaryUtil.getNameByValueForDefault("XueshuchengguoJb", oldTAcadeAchiveInfo.getLevel()));// 级别
			oldTAcadeAchiveInfo.setAcadType(SysDictionaryUtil.getNameByValueForDefault("XueshuchengguoType",
					oldTAcadeAchiveInfo.getAcadType()));// 类别
			tAcadeAchiveInfo.setLevel(
					SysDictionaryUtil.getNameByValueForDefault("XueshuchengguoJb", tAcadeAchiveInfo.getLevel()));// 级别
			tAcadeAchiveInfo.setAcadType(
					SysDictionaryUtil.getNameByValueForDefault("XueshuchengguoType", tAcadeAchiveInfo.getAcadType()));// 类别
			List<TPartRank> tPartRanks = tAcadeAchiveInfo.gettPartRankList();
			if (tPartRanks.size() > 0) {
				for (TPartRank rank : tPartRanks) {
					rank.setRoleName(SysDictionaryUtil.getNameByValueForDefault("XueshuchengguoJs", rank.getRole()));
				}
			}
			addRecordLogInfo(tAcadeAchiveInfo, oldTAcadeAchiveInfo, user, tAcadeAchiveInfo.getPrimitiveId(),
					tAcadeAchiveInfo.getId(), "2");
		}
		return null;
	}

	@Override
	public TAcadeAchiveInfo getAcadeAchiveInfoByIdForRecord(String id) {
		TAcadeAchiveInfo tAcadeAchiveInfo = userInfoDao.getAcadeAchiveInfoByIdForRecord(id);
		if (tAcadeAchiveInfo != null) {
			List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(new HashSet<String>() {
				{
					add(id);
				}
			}, "12");
			tAcadeAchiveInfo.settPartRankList(tPartRankList);
		}
		return tAcadeAchiveInfo;
	}

	@Override
	public TAcadeAchiveInfoVo getAcadeAchiveInfoById(String id) {
		TAcadeAchiveInfoVo tAcadeAchiveInfoVo = userInfoDao.getAcadeAchiveInfoById(id);
		if (tAcadeAchiveInfoVo != null) {
			List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(new HashSet<String>() {
				{
					add(id);
				}
			}, "12");
			tAcadeAchiveInfoVo.settPartRankList(tPartRankList);
		}
		return tAcadeAchiveInfoVo;
	}

	@Override
	public List<TAcadeAchiveInfoVo> getAcadeAchiveInfoByErpNo(String erpNo) {
		List<TAcadeAchiveInfoVo> tAcadeAchiveInfoVos = userInfoDao.getAcadeAchiveInfoByErpNo(erpNo);

		if (tAcadeAchiveInfoVos.isEmpty()) {
			return tAcadeAchiveInfoVos;
		}
		Set<String> ids = new HashSet<>();
		tAcadeAchiveInfoVos.forEach(i -> ids.add(i.getId()));
		List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(ids, "12");
		if (!tPartRankList.isEmpty()) {
			for (TAcadeAchiveInfoVo tAcadeAchiveInfoVo : tAcadeAchiveInfoVos) {
				List<TPartRank> tPartRankListVo = new ArrayList<>();
				for (TPartRank tPartRank : tPartRankList) {
					if (tAcadeAchiveInfoVo.getId().equals(tPartRank.getItemId())) {
						tPartRankListVo.add(tPartRank);
					}
				}

				tAcadeAchiveInfoVo.settPartRankList(tPartRankListVo);
			}
		}
		return tAcadeAchiveInfoVos;
	}

	@Override
	public void findPageAcadeAchiveInfoByCondi(Page<TAcadeAchiveInfoVo> page, TAcadeAchiveInfo tAcadeAchiveInfo) {
		userInfoDao.findPageAcadeAchiveInfoByCondi(page, tAcadeAchiveInfo);
		if (!page.getResult().isEmpty()) {
			List<TAcadeAchiveInfoVo> tAcadeAchiveInfoVos = page.getResult();
			Set<String> ids = new HashSet<>();
			tAcadeAchiveInfoVos.forEach(i -> ids.add(i.getId()));
			List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(ids, "12");
			if (!tPartRankList.isEmpty()) {
				for (TAcadeAchiveInfoVo tAcadeAchiveInfoVo : tAcadeAchiveInfoVos) {
					List<TPartRank> tPartRankListVo = new ArrayList<>();
					for (TPartRank tPartRank : tPartRankList) {
						if (tAcadeAchiveInfoVo.getId().equals(tPartRank.getItemId())) {
							tPartRankListVo.add(tPartRank);
						}
					}

					tAcadeAchiveInfoVo.settPartRankList(tPartRankListVo);
				}
			}
		}

	}

	/**
	 * 标准制定
	 *
	 * @param tStandInfo
	 * @param user
	 * @throws Exception
	 */
	@Override
	@Transactional
	public String addStandInfo(TStandInfo tStandInfo, User user) throws Exception {
		if (!("0").equals(tStandInfo.getIsAdd())){
			List<TSalaryBusinessBind> list = userInfoDao.selectSalaryBusinessBind(t_stand_info,tStandInfo.getOrignalId());
			if(!CollectionUtils.isEmpty(list)){
				return "当前数据已用于薪档申报，不可修改！";
			}
		}
		tStandInfo.setUpdaterId(user.getFax());
		tStandInfo.setUpdaterName(user.getName());
		List<TPartRank> rankList = tStandInfo.gettPartRankList();
		// 根据erp_no过滤重复选中的人
		List<TPartRank> ranks = rankList.stream()
				.collect(Collectors.collectingAndThen(
						Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(TPartRank::getErpNo))),
						ArrayList::new));
		if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
			// 管理员给自己新增的时候要判断参与人里面有没有自己，如果给别人添加的时候要判断有没有选中当前选择的人，如果没有就不允许添加
			boolean flag = judgeTPartRankIsContainCurrentUser(ranks, tStandInfo.getErpNo());
			if (!flag) {
				// 返回错误信息
				String message = "";
				if (tStandInfo.getErpNo().equals(user.getFax())) {// 给自己添加
					message = "当前添加的参与人员中没有包含当前登录人";
				} else {// 给别人添加
					message = "当前添加的参与人员中没有包含当前选中的人";
				}
				return message;
			}
		} else {// 普通用户
				// 普通人员新增的时候要判断参与人里面有没有当前登录人，如果没有就不允许添加
			boolean flag = judgeTPartRankIsContainCurrentUser(ranks, user.getFax());
			if (!flag) {
				// 返回错误信息
				String message = "当前添加的参与人员中没有包含当前登录人自己";
				return message;
			}
		}
		// isAdd=0，表示新增，isAdd=1表示正常编辑，isAdd=2表示审核时编辑(但是审核时编辑未走当前方法，走的是WorkFlowController里面的接口方法);
		// isAdd=3表示在新增时输入名称，点击下拉框中匹配的一条数据进行回显，并进行编辑,
		// 此时如果该条数据是待审核的(即flow_status=0)，那么无论是管理员操作还是普通用户操作，状态不变，仍为待审核，
		// 如果该条数据是被驳回的，即(flow_status=3)，那么无论是管理员操作还是普通用户操作，做add操作，新增一条待审核数据，
		// 如果该条数据是有效数据，即(flow_status=1,且is_valid=0)，那么对该条数据进行编辑时走正常流程，即管理员操作后仍是有效数据，普通用户操作新增一条待审核数据
		if (("3").equals(tStandInfo.getIsAdd())) {
			if (1 == tStandInfo.getFlowStatus() && 0 == tStandInfo.getIsValid()) {// 有效的数据
				tStandInfo.setIsAdd("1");// 走正常编辑流程
			} else {
				String recordId = "";
				if (3 == tStandInfo.getFlowStatus()) {// 被驳回的
					// 将该条数据状态由被驳回变更为待审核
					tStandInfo.setFlowStatus(0);// 待审核
					tStandInfo.setIsValid(1);
					userInfoDao.addStandInfo(tStandInfo);
					addPartRank(ranks, tStandInfo.getId(), "13");
					// 插入工作流
					workFlowAntService.addWorkFlow(user, t_stand_info, tStandInfo.getId(), null, null);
					recordId = tStandInfo.getProgressCheckId();
				} else {// 待审核
						// 待审核状态的数据状态不变，只能修改参与人
					updatePartRankData(tStandInfo.getId(), ranks, "13");
					recordId = tStandInfo.getId();
				}
				// 插入日志
				TStandInfo oldTStandInfo = getStandInfoByIdForRecord(recordId);
				List<TPartRank> tPartRanks = tStandInfo.gettPartRankList();
				if (tPartRanks.size() > 0) {
					for (TPartRank rank : tPartRanks) {
						rank.setRoleName(
								SysDictionaryUtil.getNameByValueForDefault("XueshuchengguoJs", rank.getRole()));
					}
				}
				addRecordLogInfo(tStandInfo, oldTStandInfo, user, tStandInfo.getPrimitiveId(), tStandInfo.getId(), "2");
			}
		}
		if (("0").equals(tStandInfo.getIsAdd())) {// 新增
			// 判断标准名称是否重复--查询对象：有效的、待审核的、被驳回的,不通过的除外
			List<TStandInfoVo> list = userInfoDao.getStandInfoByName(tStandInfo.getName(), user.getBaseOrgId());
			if (list != null && list.size() > 0) {
				return "该标准名称已存在，请在填写名称时选择下拉项进行编辑";
			}
			tStandInfo.setCreaterId(user.getFax());
			tStandInfo.setCreaterName(user.getName());
			tStandInfo.setOrgId(user.getBaseOrgId());// 单位ID
			tStandInfo.setOrignalId(tStandInfo.getId());
			tStandInfo.setPrimitiveId(tStandInfo.getId());
			tStandInfo.setBusinessTypeId(t_stand_info);
			tStandInfo.setDelSign(0);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				tStandInfo.setIsValid(0);
				tStandInfo.setFlowStatus(1);// 不要审批，默认通过
			} else {
				tStandInfo.setIsValid(1);
				tStandInfo.setFlowStatus(0);// 要审批
			}
			userInfoDao.addStandInfo(tStandInfo);
			addPartRank(ranks, tStandInfo.getId(), "13");
			// 新增插入操作记录
			addRecordLogData(tStandInfo.getId(), user, "0");
			// 删除草稿箱数据
			draftsService.deleteMes(tStandInfo.getId(), "t_stand_info_drafts");
			// 删除草稿箱列表数据
			draftsService.deleteDraftsListByBusinessId(tStandInfo.getId());
			// 插入工作流
			if (!(("2").equals(user.getRemark()) || ("3").equals(user.getRemark()))) {// 非管理员
				workFlowAntService.addWorkFlow(user, t_stand_info, tStandInfo.getId(), null, null);
			}
		} else if (("1").equals(tStandInfo.getIsAdd()) || ("2").equals(tStandInfo.getIsAdd())) {
			//待审核可编辑-xyy
			/*if ("1".equals(tStandInfo.getIsAdd())) {
				List<TStandInfo> tStandInfos = getReadyStandInfoById(tStandInfo.getId());
				if (tStandInfos != null && tStandInfos.size() > 0) {
					return "当前数据已经存在待审核状态";
				}
			}*/
			// 防止数据直接从数据库维护进去，business_type_id为空，再次编辑的时候还是为空
			tStandInfo.setBusinessTypeId(t_stand_info);
			// 日志记录--获取原始业务数据
			String orignalId = "";
			if (!(StringUtil.isNullOrEmpty(tStandInfo.getProgressCheckId()))) {// 如果是进度查看里的编辑
				orignalId = tStandInfo.getProgressCheckId();
			} else {
				orignalId = tStandInfo.getOrignalId();
			}
			TStandInfo oldTStandInfo = getStandInfoByIdForRecord(orignalId);
			//待审核编辑不新增流程-xyy
			List<TStandInfo> tStandInfos = getReadyStandInfoById(tStandInfo.getOrignalId());
			if ("1".equals(tStandInfo.getIsAdd()) && tStandInfos != null && tStandInfos.size() > 0) {
				tStandInfo.setId(tStandInfo.getOrignalId());
				workFlowProcessService.updateTStandInfo(tStandInfo, user);
				// 参与人员修改
				updatePartRankData(tStandInfo.getId(), ranks, "13");
			}else{
				if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
					tStandInfo.setFlowStatus(1);
					workFlowProcessService.updateTStandInfo(tStandInfo, user);
					// 参与人员修改
					updatePartRankData(tStandInfo.getId(), ranks, "13");
				} else {// 普通用户
					tStandInfo.setIsValid(1);
					tStandInfo.setCreaterId(user.getFax());
					tStandInfo.setCreaterName(user.getName());
					tStandInfo.setOrgId(user.getBaseOrgId());
					tStandInfo.setFlowStatus(0);// 要审批
//				tStandInfo.setOrignalId(tStandInfo.getId());
//				tStandInfo.setId(IdGen.uuid());
					// 参与人员修改
					addPartRank(ranks, tStandInfo.getId(), "13");
					userInfoDao.addStandInfo(tStandInfo);

					// 添加流程-add by yangwang 20200803
					/*
					 * //先删除之前的审批流程 updateWorkFlowDataByPrimitiveId(tStandInfo.getPrimitiveId());
					 * addWorkFlowData(tStandInfo.getId(),tStandInfo.getPrimitiveId(),tStandInfo.
					 * getAuditErpNo(),t_stand_info,user.getFax(),dealRoleCode);
					 */
					workFlowAntService.addWorkFlow(user, t_stand_info, tStandInfo.getId(), null, null);
				}
			}

			// 修改插入操作记录
//			addRecordLogData(tStandInfo.getPrimitiveId(),user,"2");
			oldTStandInfo.setType(SysDictionaryUtil.getNameByValueForDefault("ZdbzType", oldTStandInfo.getType()));// 类别
			oldTStandInfo.setLevel(SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb", oldTStandInfo.getLevel()));// 级别
			tStandInfo.setType(SysDictionaryUtil.getNameByValueForDefault("ZdbzType", tStandInfo.getType()));// 类别
			tStandInfo.setLevel(SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb", tStandInfo.getLevel()));// 级别
			List<TPartRank> tPartRanks = tStandInfo.gettPartRankList();
			if (tPartRanks.size() > 0) {
				for (TPartRank rank : tPartRanks) {
					rank.setRoleName(SysDictionaryUtil.getNameByValueForDefault("XueshuchengguoJs", rank.getRole()));
				}
			}
			addRecordLogInfo(tStandInfo, oldTStandInfo, user, tStandInfo.getPrimitiveId(), tStandInfo.getId(), "2");
		}
		return null;
	}

	@Override
	public TStandInfo getStandInfoByIdForRecord(String id) {
		TStandInfo tStandInfo = userInfoDao.getStandInfoByIdForRecord(id);
		if (tStandInfo != null) {
			List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(new HashSet<String>() {
				{
					add(id);
				}
			}, "13");
			tStandInfo.settPartRankList(tPartRankList);
		}
		return tStandInfo;
	}

	@Override
	public TStandInfoVo getStandInfoById(String id) {
		TStandInfoVo tStandInfoVo = userInfoDao.getStandInfoById(id);
		if (tStandInfoVo != null) {
			List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(new HashSet<String>() {
				{
					add(id);
				}
			}, "13");
			tStandInfoVo.settPartRankList(tPartRankList);
		}
		return tStandInfoVo;
	}

	@Override
	public List<TStandInfoVo> getStandInfoByErpNo(String erpNo) {
		List<TStandInfoVo> tStandInfoVos = userInfoDao.getStandInfoByErpNo(erpNo);
		if (tStandInfoVos.isEmpty()) {
			return tStandInfoVos;
		}
		Set<String> ids = new HashSet<>();
		tStandInfoVos.forEach(i -> ids.add(i.getId()));
		List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(ids, "13");
		if (!tPartRankList.isEmpty()) {
			for (TStandInfoVo tStandInfoVo : tStandInfoVos) {
				List<TPartRank> tPartRankListVo = new ArrayList<>();
				for (TPartRank tPartRank : tPartRankList) {
					if (tStandInfoVo.getId().equals(tPartRank.getItemId())) {
						tPartRankListVo.add(tPartRank);
					}
				}

				tStandInfoVo.settPartRankList(tPartRankListVo);
			}
		}
		return tStandInfoVos;

	}

	@Override
	public void findPageStandInfoByCondi(Page<TStandInfoVo> page, TStandInfo tStandInfo) {
		userInfoDao.findPageStandInfoByCondi(page, tStandInfo);
		if (!page.getResult().isEmpty()) {
			List<TStandInfoVo> tStandInfoVos = page.getResult();
			Set<String> ids = new HashSet<>();
			tStandInfoVos.forEach(i -> ids.add(i.getId()));
			List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(ids, "13");
			if (!tPartRankList.isEmpty()) {
				for (TStandInfoVo tStandInfoVo : tStandInfoVos) {
					List<TPartRank> tPartRankListVo = new ArrayList<>();
					for (TPartRank tPartRank : tPartRankList) {
						if (tStandInfoVo.getId().equals(tPartRank.getItemId())) {
							tPartRankListVo.add(tPartRank);
						}
					}

					tStandInfoVo.settPartRankList(tPartRankListVo);
				}
			}
		}
	}

	/**
	 * 专利信息
	 *
	 * @param tPatentInfo
	 * @param user
	 * @throws Exception
	 */
	@Override
	@Transactional
	public String addPatentInfo(TPatentInfo tPatentInfo, User user) throws Exception {
		if (!("0").equals(tPatentInfo.getIsAdd())){
			List<TSalaryBusinessBind> list = userInfoDao.selectSalaryBusinessBind(t_patent_info,tPatentInfo.getOrignalId());
			if(!CollectionUtils.isEmpty(list)){
				return "当前数据已用于薪档申报，不可修改！";
			}
		}

		tPatentInfo.setUpdaterId(user.getFax());
		tPatentInfo.setUpdaterName(user.getName());
		List<TPartRank> rankList = tPatentInfo.gettPartRankList();
		// 根据erp_no过滤重复选中的人
		List<TPartRank> ranks = rankList.stream()
				.collect(Collectors.collectingAndThen(
						Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(TPartRank::getErpNo))),
						ArrayList::new));
		if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
			// 管理员给自己新增的时候要判断参与人里面有没有自己，如果给别人添加的时候要判断有没有选中当前选择的人，如果没有就不允许添加
			boolean flag = judgeTPartRankIsContainCurrentUser(ranks, tPatentInfo.getErpNo());
			if (!flag) {
				// 返回错误信息
				String message = "";
				if (tPatentInfo.getErpNo().equals(user.getFax())) {// 给自己添加
					message = "当前添加的参与人员中没有包含当前登录人";
				} else {// 给别人添加
					message = "当前添加的参与人员中没有包含当前选中的人";
				}
				return message;
			}
		} else {// 普通用户
				// 普通人员新增的时候要判断参与人里面有没有当前登录人，如果没有就不允许添加
			boolean flag = judgeTPartRankIsContainCurrentUser(ranks, user.getFax());
			if (!flag) {
				// 返回错误信息
				String message = "当前添加的参与人员中没有包含当前登录人自己";
				return message;
			}
		}
		// isAdd=0，表示新增，isAdd=1表示正常编辑，isAdd=2表示审核时编辑(但是审核时编辑未走当前方法，走的是WorkFlowController里面的接口方法);
		// isAdd=3表示在新增时输入专利名称，点击下拉框中匹配的一条数据进行回显，并进行编辑,
		// 此时如果该条数据是待审核的(即flow_status=0)，那么无论是管理员操作还是普通用户操作，状态不变，仍为待审核，
		// 如果该条数据是被驳回的，即(flow_status=3)，那么无论是管理员操作还是普通用户操作，做add操作，新增一条待审核数据，
		// 如果该条数据是有效数据，即(flow_status=1,且is_valid=0)，那么对该条数据进行编辑时走正常流程，即管理员操作后仍是有效数据，普通用户操作新增一条待审核数据
		if (("3").equals(tPatentInfo.getIsAdd())) {
			if (1 == tPatentInfo.getFlowStatus() && 0 == tPatentInfo.getIsValid()) {// 有效的数据
				tPatentInfo.setIsAdd("1");// 走正常编辑流程
			} else {
				String recordId = "";
				if (3 == tPatentInfo.getFlowStatus()) {// 被驳回的
					// 将该条数据状态由被驳回变更为待审核
					tPatentInfo.setFlowStatus(0);// 待审核
					tPatentInfo.setIsValid(1);
					userInfoDao.addPatentInfo(tPatentInfo);
					addPartRank(ranks, tPatentInfo.getId(), "14");
					// 插入工作流
					workFlowAntService.addWorkFlow(user, t_patent_info, tPatentInfo.getId(), null, null);
					recordId = tPatentInfo.getProgressCheckId();
				} else {// 待审核
						// 待审核状态的数据状态不变，只能修改参与人
					updatePartRankData(tPatentInfo.getId(), ranks, "14");
					recordId = tPatentInfo.getId();
				}
				// 插入日志
				TPatentInfo oldTPatentInfo = getPatentInfoByIdForRecord(recordId);
				addRecordLogInfo(tPatentInfo, oldTPatentInfo, user, tPatentInfo.getPrimitiveId(), tPatentInfo.getId(),
						"2");
			}
		}
		if (("0").equals(tPatentInfo.getIsAdd())) {// 新增
			// 判断专利名称是否重复--查询对象：有效的、待审核的、被驳回的,不通过的除外
			List<TPatentInfoVo> list = userInfoDao.getPatentInfoByPatentName(tPatentInfo.getPatentName(),
					user.getBaseOrgId());
			if (list != null && list.size() > 0) {
				return "该专利名称已存在，请在填写名称时选择下拉项进行编辑";
			}
			tPatentInfo.setCreaterId(user.getFax());
			tPatentInfo.setCreaterName(user.getName());
			tPatentInfo.setOrgId(user.getBaseOrgId());// 单位ID
			tPatentInfo.setOrignalId(tPatentInfo.getId());
			tPatentInfo.setPrimitiveId(tPatentInfo.getId());
			tPatentInfo.setBusinessTypeId(t_patent_info);
			tPatentInfo.setDelSign(0);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				tPatentInfo.setIsValid(0);// 有效
				tPatentInfo.setFlowStatus(1);// 不要审批，默认通过
			} else {
				tPatentInfo.setIsValid(1);// 无效
				tPatentInfo.setFlowStatus(0);// 要审批

				// 添加流程-add by yangwang 20200803
				/*
				 * //先删除之前的审批流程 //updateWorkFlowDataByPrimitiveId(tPatentInfo.getPrimitiveId());
				 * addWorkFlowData(tPatentInfo.getId(),tPatentInfo.getPrimitiveId(),tPatentInfo.
				 * getAuditErpNo(),t_patent_info,user.getFax(),dealRoleCode);
				 */
//				workFlowAntService.addWorkFlow(user, t_patent_info, tPatentInfo.getId(), null, null);
			}
			userInfoDao.addPatentInfo(tPatentInfo);
			addPartRank(ranks, tPatentInfo.getId(), "14");
			// 新增插入操作记录
			addRecordLogData(tPatentInfo.getId(), user, "0");
			// 删除草稿箱数据
			draftsService.deleteMes(tPatentInfo.getId(), "t_patent_info_drafts");
			// 删除草稿箱列表数据
			draftsService.deleteDraftsListByBusinessId(tPatentInfo.getId());
			// 插入工作流
			if (!(("2").equals(user.getRemark()) || ("3").equals(user.getRemark()))) {// 非管理员
				workFlowAntService.addWorkFlow(user, t_patent_info, tPatentInfo.getId(), null, null);
			}
		} else if (("1").equals(tPatentInfo.getIsAdd()) || ("2").equals(tPatentInfo.getIsAdd())) {
			//待审核可编辑-xyy
			/*if ("1".equals(tPatentInfo.getIsAdd())) {
				List<TPatentInfo> tPatentInfos = getReadyPatentInfoById(tPatentInfo.getId());
				if (tPatentInfos != null && tPatentInfos.size() > 0) {
					return "当前数据已经存在待审核状态";
				}
			}*/
			// 防止数据直接从数据库维护进去，business_type_id为空，再次编辑的时候还是为空
			tPatentInfo.setBusinessTypeId(t_patent_info);
			// 日志记录--获取原始业务数据
			String orignalId = "";
			if (!(StringUtil.isNullOrEmpty(tPatentInfo.getProgressCheckId()))) {// 如果是进度查看里的编辑
				orignalId = tPatentInfo.getProgressCheckId();
			} else {
				orignalId = tPatentInfo.getOrignalId();
			}
			TPatentInfo oldTPatentInfo = getPatentInfoByIdForRecord(orignalId);
			//待审核编辑不新增流程-xyy
			List<TPatentInfo> tPatentInfos = getReadyPatentInfoById(tPatentInfo.getOrignalId());
			if ("1".equals(tPatentInfo.getIsAdd()) && tPatentInfos != null && tPatentInfos.size() > 0) {
				tPatentInfo.setId(tPatentInfo.getOrignalId());
				workFlowProcessService.updateTPatentInfo(tPatentInfo, user);
				// 参与人员修改
				updatePartRankData(tPatentInfo.getId(), ranks, "14");
			}else{
				if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
					tPatentInfo.setFlowStatus(1);
					workFlowProcessService.updateTPatentInfo(tPatentInfo, user);
					// 参与人员修改
					updatePartRankData(tPatentInfo.getId(), ranks, "14");
				} else {// 普通用户
					tPatentInfo.setIsValid(1);// 无效
					tPatentInfo.setCreaterId(user.getFax());
					tPatentInfo.setCreaterName(user.getName());
					tPatentInfo.setOrgId(user.getBaseOrgId());
					tPatentInfo.setFlowStatus(0);// 要审批
//				tPatentInfo.setOrignalId(tPatentInfo.getId());
//				tPatentInfo.setId(IdGen.uuid());
					// 参与人员修改
					addPartRank(ranks, tPatentInfo.getId(), "14");
					userInfoDao.addPatentInfo(tPatentInfo);

					// 添加流程-add by yangwang 20200803
					workFlowAntService.addWorkFlow(user, t_patent_info, tPatentInfo.getId(), null, null);
				}
			}

			// 修改插入操作记录
			oldTPatentInfo.setPatentType(
					SysDictionaryUtil.getNameByValueForDefault("PatentType", oldTPatentInfo.getPatentType()));// 类别
			tPatentInfo.setPatentType(
					SysDictionaryUtil.getNameByValueForDefault("PatentType", tPatentInfo.getPatentType()));// 类别
			addRecordLogInfo(tPatentInfo, oldTPatentInfo, user, tPatentInfo.getPrimitiveId(), tPatentInfo.getId(), "2");
		}
		return null;
	}

	@Override
	public TPatentInfo getPatentInfoByIdForRecord(String id) {
		TPatentInfo tPatentInfo = userInfoDao.getPatentInfoByIdForRecord(id);
		if (tPatentInfo != null) {
			List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(new HashSet<String>() {
				{
					add(id);
				}
			}, "14");
			tPatentInfo.settPartRankList(tPartRankList);
		}
		return tPatentInfo;
	}

	@Override
	public TPatentInfoVo getPatentInfoById(String id) {
		TPatentInfoVo tPatentInfoVo = userInfoDao.getPatentInfoById(id);
		if (tPatentInfoVo != null) {
			List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(new HashSet<String>() {
				{
					add(id);
				}
			}, "14");
			tPatentInfoVo.settPartRankList(tPartRankList);
		}
		return tPatentInfoVo;
	}

	@Override
	public List<TPatentInfoVo> getPatentInfoByErpNo(String erpNo) {

		List<TPatentInfoVo> tPatentInfoVos = userInfoDao.getPatentInfoByErpNo(erpNo);
		if (tPatentInfoVos.isEmpty()) {
			return tPatentInfoVos;
		}
		Set<String> ids = new HashSet<>();
		tPatentInfoVos.forEach(i -> ids.add(i.getId()));
		List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(ids, "14");
		if (!tPatentInfoVos.isEmpty()) {
			for (TPatentInfoVo tPatentInfoVo : tPatentInfoVos) {
				List<TPartRank> tPartRankVo = new ArrayList<>();
				for (TPartRank tPartRank : tPartRankList) {
					if (tPatentInfoVo.getId().equals(tPartRank.getItemId())) {
						tPartRankVo.add(tPartRank);
					}
				}

				tPatentInfoVo.settPartRankList(tPartRankVo);
			}
		}

		return tPatentInfoVos;
	}

	@Override
	public void findPagePatentInfoByCondi(Page<TPatentInfoVo> page, TPatentInfo tPatentInfo) {
		userInfoDao.findPagePatentInfoByCondi(page, tPatentInfo);
		if (!page.getResult().isEmpty()) {
			List<TPatentInfoVo> tPatentInfoVos = page.getResult();
			Set<String> ids = new HashSet<>();
			tPatentInfoVos.forEach(i -> ids.add(i.getId()));
			List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(ids, "14");
			if (!tPatentInfoVos.isEmpty()) {
				for (TPatentInfoVo tPatentInfoVo : tPatentInfoVos) {
					List<TPartRank> tPartRankVo = new ArrayList<>();
					for (TPartRank tPartRank : tPartRankList) {
						if (tPatentInfoVo.getId().equals(tPartRank.getItemId())) {
							tPartRankVo.add(tPartRank);
						}
					}

					tPatentInfoVo.settPartRankList(tPartRankVo);
				}
			}
		}
	}

	/**
	 * 技艺革新
	 *
	 * @param tTecInnovInfo
	 * @param user
	 * @throws Exception
	 */

	@Override
	@Transactional
	public String addTecInnovInfo(TTecInnovInfo tTecInnovInfo, User user) throws Exception {
		if (!("0").equals(tTecInnovInfo.getIsAdd())){
			List<TSalaryBusinessBind> list = userInfoDao.selectSalaryBusinessBind(t_tec_innov_info,tTecInnovInfo.getOrignalId());
			if(!CollectionUtils.isEmpty(list)){
				return "当前数据已用于薪档申报，不可修改！";
			}
		}

		tTecInnovInfo.setUpdaterId(user.getFax());
		tTecInnovInfo.setUpdaterName(user.getName());
		List<TPartRank> rankList = tTecInnovInfo.gettPartRankList();
		// 根据erp_no过滤重复选中的人
		List<TPartRank> ranks = rankList.stream()
				.collect(Collectors.collectingAndThen(
						Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(TPartRank::getErpNo))),
						ArrayList::new));
		if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
			// 管理员给自己新增的时候要判断参与人里面有没有自己，如果给别人添加的时候要判断有没有选中当前选择的人，如果没有就不允许添加
			boolean flag = judgeTPartRankIsContainCurrentUser(ranks, tTecInnovInfo.getErpNo());
			if (!flag) {
				// 返回错误信息
				String message = "";
				if (tTecInnovInfo.getErpNo().equals(user.getFax())) {// 给自己添加
					message = "当前添加的参与人员中没有包含当前登录人";
				} else {// 给别人添加
					message = "当前添加的参与人员中没有包含当前选中的人";
				}
				return message;
			}
		} else {// 普通用户
				// 普通人员新增的时候要判断参与人里面有没有当前登录人，如果没有就不允许添加
			boolean flag = judgeTPartRankIsContainCurrentUser(ranks, user.getFax());
			if (!flag) {
				// 返回错误信息
				String message = "当前添加的参与人员中没有包含当前登录人自己";
				return message;
			}
		}
		// isAdd=0，表示新增，isAdd=1表示正常编辑，isAdd=2表示审核时编辑(但是审核时编辑未走当前方法，走的是WorkFlowController里面的接口方法);
		// isAdd=3表示在新增时输入QC成果名称，点击下拉框中匹配的一条数据进行回显，并进行编辑,
		// 此时如果该条数据是待审核的(即flow_status=0)，那么无论是管理员操作还是普通用户操作，状态不变，仍为待审核，
		// 如果该条数据是被驳回的，即(flow_status=3)，那么无论是管理员操作还是普通用户操作，做add操作，新增一条待审核数据，
		// 如果该条数据是有效数据，即(flow_status=1,且is_valid=0)，那么对该条数据进行编辑时走正常流程，即管理员操作后仍是有效数据，普通用户操作新增一条待审核数据
		if (("3").equals(tTecInnovInfo.getIsAdd())) {
			if (1 == tTecInnovInfo.getFlowStatus() && 0 == tTecInnovInfo.getIsValid()) {// 有效的数据
				tTecInnovInfo.setIsAdd("1");// 走正常编辑流程
			} else {
				String recordId = "";
				if (3 == tTecInnovInfo.getFlowStatus()) {// 被驳回的
					// 将该条数据状态由被驳回变更为待审核
					tTecInnovInfo.setFlowStatus(0);// 待审核
					tTecInnovInfo.setIsValid(1);
					userInfoDao.addTecInnovInfo(tTecInnovInfo);
					addPartRank(ranks, tTecInnovInfo.getId(), "15");
					// 插入工作流
					workFlowAntService.addWorkFlow(user, t_tec_innov_info, tTecInnovInfo.getId(), null, null);
					recordId = tTecInnovInfo.getProgressCheckId();
				} else {// 待审核
						// 待审核状态的数据状态不变，只能修改参与人
					updatePartRankData(tTecInnovInfo.getId(), ranks, "15");
					recordId = tTecInnovInfo.getId();
				}
				// 插入日志
				TTecInnovInfo oldTTecInnovInfo = getTecInnovInfoByIdForRecord(recordId);
				addRecordLogInfo(tTecInnovInfo, oldTTecInnovInfo, user, tTecInnovInfo.getPrimitiveId(),
						tTecInnovInfo.getId(), "2");
			}
		}
		if (("0").equals(tTecInnovInfo.getIsAdd())) {// 新增
			// 判断成果名称是否重复--查询对象：有效的、待审核的、被驳回的,不通过的除外
			List<TTecInnovInfoVo> list = userInfoDao.getTecInnovInfoByAchiName(tTecInnovInfo.getAchiName(),
					user.getBaseOrgId());
			if (list != null && list.size() > 0) {
				return "该成果名称已存在，请在填写名称时选择下拉项进行编辑";
			}
			tTecInnovInfo.setCreaterId(user.getFax());
			tTecInnovInfo.setCreaterName(user.getName());
			tTecInnovInfo.setOrgId(user.getBaseOrgId());// 单位ID
			tTecInnovInfo.setOrignalId(tTecInnovInfo.getId());
			tTecInnovInfo.setPrimitiveId(tTecInnovInfo.getId());
			tTecInnovInfo.setBusinessTypeId(t_tec_innov_info);
			tTecInnovInfo.setDelSign(0);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				tTecInnovInfo.setIsValid(0);// 有效
				tTecInnovInfo.setFlowStatus(1);// 不要审批，默认通过
			} else {
				tTecInnovInfo.setIsValid(1);// 无效
				tTecInnovInfo.setFlowStatus(0);// 要审批

				// 添加流程-add by yangwang 20200803
				/*
				 * //先删除之前的审批流程
				 * //updateWorkFlowDataByPrimitiveId(tTecInnovInfo.getPrimitiveId());
				 * addWorkFlowData(tTecInnovInfo.getId(),tTecInnovInfo.getPrimitiveId(),
				 * tTecInnovInfo.getAuditErpNo(),t_tec_innov_info,user.getFax(),dealRoleCode);
				 */
//				workFlowAntService.addWorkFlow(user, t_tec_innov_info, tTecInnovInfo.getId(), null, null);
			}
			userInfoDao.addTecInnovInfo(tTecInnovInfo);
			addPartRank(ranks, tTecInnovInfo.getId(), "15");
			// 新增插入操作记录
			addRecordLogData(tTecInnovInfo.getId(), user, "0");
			// 删除草稿箱数据
			draftsService.deleteMes(tTecInnovInfo.getId(), "t_tec_innov_info_drafts");
			// 删除草稿箱列表数据
			draftsService.deleteDraftsListByBusinessId(tTecInnovInfo.getId());
			// 插入工作流
			if (!(("2").equals(user.getRemark()) || ("3").equals(user.getRemark()))) {// 非管理员
				workFlowAntService.addWorkFlow(user, t_tec_innov_info, tTecInnovInfo.getId(), null, null);
			}
		} else if (("1").equals(tTecInnovInfo.getIsAdd()) || ("2").equals(tTecInnovInfo.getIsAdd())) {
			//待审核可编辑-xyy
			/*if ("1".equals(tTecInnovInfo.getIsAdd())) {
				List<TTecInnovInfo> tTecInnovInfos = getReadyTecInnovInfoById(tTecInnovInfo.getId());
				if (tTecInnovInfos != null && tTecInnovInfos.size() > 0) {
					return "当前数据已经存在待审核状态";
				}
			}*/
			// 防止数据直接从数据库维护进去，business_type_id为空，再次编辑的时候还是为空
			tTecInnovInfo.setBusinessTypeId(t_tec_innov_info);
			// 日志记录--获取原始业务数据
			String orignalId = "";
			if (!(StringUtil.isNullOrEmpty(tTecInnovInfo.getProgressCheckId()))) {// 如果是进度查看里的编辑
				orignalId = tTecInnovInfo.getProgressCheckId();
			} else {
				orignalId = tTecInnovInfo.getOrignalId();
			}
			TTecInnovInfo oldTTecInnovInfo = getTecInnovInfoByIdForRecord(orignalId);
			//待审核编辑不新增流程-xyy
			List<TTecInnovInfo> tTecInnovInfos = getReadyTecInnovInfoById(tTecInnovInfo.getOrignalId());
			if ("1".equals(tTecInnovInfo.getIsAdd()) && tTecInnovInfos != null && tTecInnovInfos.size() > 0) {
				tTecInnovInfo.setId(tTecInnovInfo.getOrignalId());
				workFlowProcessService.updateTTecInnovInfo(tTecInnovInfo, user);
				// 参与人员修改
				updatePartRankData(tTecInnovInfo.getId(), ranks, "15");
			}else {
				if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
					tTecInnovInfo.setFlowStatus(1);
					workFlowProcessService.updateTTecInnovInfo(tTecInnovInfo, user);
					// 参与人员修改
					updatePartRankData(tTecInnovInfo.getId(), ranks, "15");
				} else {// 普通用户
					tTecInnovInfo.setIsValid(1);// 无效
					tTecInnovInfo.setCreaterId(user.getFax());
					tTecInnovInfo.setCreaterName(user.getName());
					tTecInnovInfo.setOrgId(user.getBaseOrgId());
					tTecInnovInfo.setFlowStatus(0);// 要审批
//				tTecInnovInfo.setOrignalId(tTecInnovInfo.getId());
//				tTecInnovInfo.setId(IdGen.uuid());
					// 参与人员修改
					addPartRank(ranks, tTecInnovInfo.getId(), "15");
					userInfoDao.addTecInnovInfo(tTecInnovInfo);

					// 添加流程-add by yangwang 20200803
					/*
					 * //先删除之前的审批流程 updateWorkFlowDataByPrimitiveId(tTecInnovInfo.getPrimitiveId());
					 * addWorkFlowData(tTecInnovInfo.getId(),tTecInnovInfo.getPrimitiveId(),
					 * tTecInnovInfo.getAuditErpNo(),t_tec_innov_info,user.getFax(),dealRoleCode);
					 */
					workFlowAntService.addWorkFlow(user, t_tec_innov_info, tTecInnovInfo.getId(), null, null);
				}
			}

			// 修改插入操作记录
//			addRecordLogData(tTecInnovInfo.getPrimitiveId(),user,"2");
			oldTTecInnovInfo.setAwardLevel(
					SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb", oldTTecInnovInfo.getAwardLevel()));// QC获奖级别
			oldTTecInnovInfo.setAwardGrade(
					SysDictionaryUtil.getNameByValueForDefault("JygexinQcDj", oldTTecInnovInfo.getAwardGrade()));// 奖项等级
			oldTTecInnovInfo.setAwardType(
					SysDictionaryUtil.getNameByValueForDefault("jiyigexinType", oldTTecInnovInfo.getAwardType()));// 类型
			tTecInnovInfo.setAwardLevel(
					SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb", tTecInnovInfo.getAwardLevel()));// QC获奖级别
			tTecInnovInfo.setAwardGrade(
					SysDictionaryUtil.getNameByValueForDefault("JygexinQcDj", tTecInnovInfo.getAwardGrade()));// 奖项等级
			tTecInnovInfo.setAwardType(
					SysDictionaryUtil.getNameByValueForDefault("jiyigexinType", tTecInnovInfo.getAwardType())); //类型
			addRecordLogInfo(tTecInnovInfo, oldTTecInnovInfo, user, tTecInnovInfo.getPrimitiveId(),
					tTecInnovInfo.getId(), "2");
		}
		return null;
	}

	@Override
	public TTecInnovInfo getTecInnovInfoByIdForRecord(String id) {
		TTecInnovInfo tTecInnovInfo = userInfoDao.getTecInnovInfoByIdForRecord(id);
		if (tTecInnovInfo != null) {
			List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(new HashSet<String>() {
				{
					add(id);
				}
			}, "15");
			tTecInnovInfo.settPartRankList(tPartRankList);
		}
		return tTecInnovInfo;
	}

	@Override
	public TTecInnovInfoVo getTecInnovInfoById(String id) {
		TTecInnovInfoVo tTecInnovInfoVo = userInfoDao.getTecInnovInfoById(id);
		if (tTecInnovInfoVo != null) {
			List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(new HashSet<String>() {
				{
					add(id);
				}
			}, "15");
			tTecInnovInfoVo.settPartRankList(tPartRankList);
		}
		return tTecInnovInfoVo;
	}

	@Override
	public List<TTecInnovInfoVo> getTecInnovInfoByErpNo(String erpNo) {

		List<TTecInnovInfoVo> tTecInnovInfoVos = userInfoDao.getTecInnovInfoByErpNo(erpNo);
		if (tTecInnovInfoVos.isEmpty()) {
			return tTecInnovInfoVos;
		}
		Set<String> ids = new HashSet<>();
		tTecInnovInfoVos.forEach(i -> ids.add(i.getId()));
		List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(ids, "15");
		if (!tPartRankList.isEmpty()) {
			for (TTecInnovInfoVo tTecInnovInfoVo : tTecInnovInfoVos) {
				List<TPartRank> tPartRankListVo = new ArrayList<>();
				for (TPartRank tPartRank : tPartRankList) {
					if (tTecInnovInfoVo.getId().equals(tPartRank.getItemId())) {
						tPartRankListVo.add(tPartRank);
					}
				}

				tTecInnovInfoVo.settPartRankList(tPartRankListVo);
			}
		}

		return tTecInnovInfoVos;
	}

	@Override
	public void findPageTecInnovInfoByCondi(Page<TTecInnovInfoVo> page, TTecInnovInfo tTecInnovInfo) {
		userInfoDao.findPageTecInnovInfoByCondi(page, tTecInnovInfo);
		if (!page.getResult().isEmpty()) {
			List<TTecInnovInfoVo> tTecInnovInfoVos = page.getResult();
			Set<String> ids = new HashSet<>();
			tTecInnovInfoVos.forEach(i -> ids.add(i.getId()));
			List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(ids, "15");
			if (!tPartRankList.isEmpty()) {
				for (TTecInnovInfoVo tTecInnovInfoVo : tTecInnovInfoVos) {
					List<TPartRank> tPartRankListVo = new ArrayList<>();
					for (TPartRank tPartRank : tPartRankList) {
						if (tTecInnovInfoVo.getId().equals(tPartRank.getItemId())) {
							tPartRankListVo.add(tPartRank);
						}
					}

					tTecInnovInfoVo.settPartRankList(tPartRankListVo);
				}
			}
		}
	}

	/**
	 * 竞赛考试
	 *
	 * @param tContestInfo
	 * @param user
	 * @throws Exception
	 */
	@Override
	@Transactional
	public String addContestInfo(TContestInfo tContestInfo, User user) throws Exception {
		tContestInfo.setUpdaterId(user.getFax());
		tContestInfo.setUpdaterName(user.getName());
		if (tContestInfo.getIsAdd().equals("0")) {// 新增
			tContestInfo.setCreaterId(user.getFax());
			tContestInfo.setCreaterName(user.getName());
			tContestInfo.setOrgId(user.getBaseOrgId());// 单位ID
			tContestInfo.setOrignalId(tContestInfo.getId());
			tContestInfo.setPrimitiveId(tContestInfo.getId());
			tContestInfo.setBusinessTypeId(t_contest_info);
			tContestInfo.setDelSign(0);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				tContestInfo.setIsValid(0);// 有效
				tContestInfo.setFlowStatus(1);// 不要审批，默认通过
			} else {
				tContestInfo.setIsValid(1);// 无效
				tContestInfo.setFlowStatus(0);// 要审批

				// 添加流程-add by yangwang 20200803
				/*
				 * //先删除之前的审批流程
				 * //updateWorkFlowDataByPrimitiveId(tContestInfo.getPrimitiveId());
				 * addWorkFlowData(tContestInfo.getId(),tContestInfo.getPrimitiveId(),
				 * tContestInfo.getAuditErpNo(),t_contest_info,user.getFax(),dealRoleCode);
				 */
//				workFlowAntService.addWorkFlow(user, t_contest_info, tContestInfo.getId(), null, null);
			}
			userInfoDao.addContestInfo(tContestInfo);
			// 新增插入操作记录
			addRecordLogData(tContestInfo.getId(), user, "0");
			// 删除草稿箱数据
			draftsService.deleteMes(tContestInfo.getId(), "t_contest_info_drafts");
			// 删除草稿箱列表数据
			draftsService.deleteDraftsListByBusinessId(tContestInfo.getId());
			// 插入工作流
			if (!(("2").equals(user.getRemark()) || ("3").equals(user.getRemark()))) {// 非管理员
				workFlowAntService.addWorkFlow(user, t_contest_info, tContestInfo.getId(), null, null);
			}
		} else {// 修改
			List<TSalaryBusinessBind> list = userInfoDao.selectSalaryBusinessBind(t_contest_info,tContestInfo.getOrignalId());
			if(!CollectionUtils.isEmpty(list)){
				return "当前数据已用于薪档申报，不可修改！";
			}
			//待审核可编辑-xyy
			/*if ("1".equals(tContestInfo.getIsAdd())) {
				List<TContestInfo> tContestInfos = getReadyContestInfoById(tContestInfo.getId());
				if (tContestInfos != null && tContestInfos.size() > 0) {
					return "当前数据已经存在待审核状态";
				}
			}*/
			// 防止数据直接从数据库维护进去，business_type_id为空，再次编辑的时候还是为空
			tContestInfo.setBusinessTypeId(t_contest_info);
			// 日志记录--获取原始业务数据
			String orignalId = "";
			if (!(StringUtil.isNullOrEmpty(tContestInfo.getProgressCheckId()))) {// 如果是进度查看里的编辑
				orignalId = tContestInfo.getProgressCheckId();
			} else {
				orignalId = tContestInfo.getOrignalId();
			}
			TContestInfo oldTContestInfo = userInfoDao.getContestInfoById(orignalId);
			//待审核编辑不新增流程-xyy
			List<TContestInfo> tContestInfos = getReadyContestInfoById(tContestInfo.getOrignalId());
			if ("1".equals(tContestInfo.getIsAdd()) && tContestInfos != null && tContestInfos.size() > 0) {
				tContestInfo.setId(tContestInfo.getOrignalId());
				workFlowProcessService.updateTContestInfo(tContestInfo, user);
			}else {
				if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
					tContestInfo.setFlowStatus(1);
					workFlowProcessService.updateTContestInfo(tContestInfo, user);
				} else {// 普通用户
					tContestInfo.setIsValid(1);// 无效
					tContestInfo.setCreaterId(user.getFax());
					tContestInfo.setCreaterName(user.getName());
					tContestInfo.setOrgId(user.getBaseOrgId());
					tContestInfo.setFlowStatus(0);// 要审批
//				tContestInfo.setOrignalId(tContestInfo.getId());
//				tContestInfo.setId(IdGen.uuid());
					userInfoDao.addContestInfo(tContestInfo);

					// 添加流程-add by yangwang 20200803
					/*
					 * //先删除之前的审批流程 updateWorkFlowDataByPrimitiveId(tContestInfo.getPrimitiveId());
					 * addWorkFlowData(tContestInfo.getId(),tContestInfo.getPrimitiveId(),
					 * tContestInfo.getAuditErpNo(),t_contest_info,user.getFax(),dealRoleCode);
					 */
					workFlowAntService.addWorkFlow(user, t_contest_info, tContestInfo.getId(), null, null);
				}
			}

			// 修改插入操作记录
//			addRecordLogData(tContestInfo.getPrimitiveId(),user,"2");
			oldTContestInfo.setAwardLevel(
					SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb", oldTContestInfo.getAwardLevel()));// 竞赛考试获奖级别
			oldTContestInfo.setCompRank(
					SysDictionaryUtil.getNameByValueForDefault("JygexinQcDj", oldTContestInfo.getCompRank()));// 竞赛考试名次
			if (oldTContestInfo.getGetTitle().equals("0")) {
				oldTContestInfo.setGetTitle("是");
			} else {
				oldTContestInfo.setGetTitle("否");
			}
			tContestInfo.setAwardLevel(
					SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb", tContestInfo.getAwardLevel()));// 竞赛考试获奖级别
			tContestInfo
					.setCompRank(SysDictionaryUtil.getNameByValueForDefault("JygexinQcDj", tContestInfo.getCompRank()));// 竞赛考试名次
			if (tContestInfo.getGetTitle().equals("0")) {
				tContestInfo.setGetTitle("是");
			} else {
				tContestInfo.setGetTitle("否");
			}
			addRecordLogInfo(tContestInfo, oldTContestInfo, user, tContestInfo.getPrimitiveId(), tContestInfo.getId(),
					"2");
		}
		return null;
	}

	@Override
	public TContestInfo getContestInfoById(String id) {
		return userInfoDao.getContestInfoById(id);
	}

	@Override
	public List<TContestInfo> getContestInfoByErpNo(String erpNo) {
		return userInfoDao.getContestInfoByErpNo(erpNo);
	}

	@Override
	public void findPageContestInfoByCondi(Page<TContestInfo> page, TContestInfo tContestInfo) {
		userInfoDao.findPageContestInfoByCondi(page, tContestInfo);
	}

	/**
	 * 科技创新成果
	 *
	 * @param tTecManInnov
	 * @param user
	 */
	@Override
	@Transactional
	public String addTecManInnov(TTecManInnov tTecManInnov, User user) throws Exception {
		if (!("0").equals(tTecManInnov.getIsAdd())){
			List<TSalaryBusinessBind> list = userInfoDao.selectSalaryBusinessBind(t_tec_man_innov,tTecManInnov.getOrignalId());
			if(!CollectionUtils.isEmpty(list)){
				return "当前数据已用于薪档申报，不可修改！";
			}
		}

		tTecManInnov.setUpdaterId(user.getFax());
		tTecManInnov.setUpdaterName(user.getName());
		List<TPartRank> rankList = tTecManInnov.gettPartRankList();
		// 根据erp_no过滤重复选中的人
		List<TPartRank> ranks = rankList.stream()
				.collect(Collectors.collectingAndThen(
						Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(TPartRank::getErpNo))),
						ArrayList::new));
		if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
			// 管理员给自己新增的时候要判断参与人里面有没有自己，如果给别人添加的时候要判断有没有选中当前选择的人，如果没有就不允许添加
			boolean flag = judgeTPartRankIsContainCurrentUser(ranks, tTecManInnov.getErpNo());
			if (!flag) {
				// 返回错误信息
				String message = "";
				if (tTecManInnov.getErpNo().equals(user.getFax())) {// 给自己添加
					message = "当前添加的参与人员中没有包含当前登录人";
				} else {// 给别人添加
					message = "当前添加的参与人员中没有包含当前选中的人";
				}
				return message;
			}
		} else {// 普通用户
				// 普通人员新增的时候要判断参与人里面有没有当前登录人，如果没有就不允许添加
			boolean flag = judgeTPartRankIsContainCurrentUser(ranks, user.getFax());
			if (!flag) {
				// 返回错误信息
				String message = "当前添加的参与人员中没有包含当前登录人自己";
				return message;
			}
		}
		// isAdd=0，表示新增，isAdd=1表示正常编辑，isAdd=2表示审核时编辑(但是审核时编辑未走当前方法，走的是WorkFlowController里面的接口方法);
		// isAdd=3表示在新增时输入成果名称，点击下拉框中匹配的一条数据进行回显，并进行编辑,
		// 此时如果该条数据是待审核的(即flow_status=0)，那么无论是管理员操作还是普通用户操作，状态不变，仍为待审核，
		// 如果该条数据是被驳回的，即(flow_status=3)，那么无论是管理员操作还是普通用户操作，做add操作，新增一条待审核数据，
		// 如果该条数据是有效数据，即(flow_status=1,且is_valid=0)，那么对该条数据进行编辑时走正常流程，即管理员操作后仍是有效数据，普通用户操作新增一条待审核数据
		if (("3").equals(tTecManInnov.getIsAdd())) {
			if (1 == tTecManInnov.getFlowStatus() && 0 == tTecManInnov.getIsValid()) {// 有效的数据
				tTecManInnov.setIsAdd("1");// 走正常编辑流程
			} else {
				String recordId = "";
				if (3 == tTecManInnov.getFlowStatus()) {// 被驳回的
					// 将该条数据状态由被驳回变更为待审核
					tTecManInnov.setFlowStatus(0);// 待审核
					tTecManInnov.setIsValid(1);
					userInfoDao.addTecManInnov(tTecManInnov);
					addPartRank(ranks, tTecManInnov.getId(), "16");
					// 插入工作流
					workFlowAntService.addWorkFlow(user, t_tec_man_innov, tTecManInnov.getId(), null, null);
					recordId = tTecManInnov.getProgressCheckId();
				} else {
					// 待审核状态的数据状态不变，只能修改参与人
					updatePartRankData(tTecManInnov.getId(), ranks, "16");
					recordId = tTecManInnov.getId();
				}
				// 插入日志
				TTecManInnov oldTTecManInnov = getTecManInnovByIdForRecord(recordId);
				addRecordLogInfo(tTecManInnov, oldTTecManInnov, user, tTecManInnov.getPrimitiveId(),
						tTecManInnov.getId(), "2");
			}
		}
		if (("0").equals(tTecManInnov.getIsAdd())) {// 新增
			// 判断成果名称是否重复--查询对象：有效的、待审核的、被驳回的,不通过的除外
			List<TTecManInnovVo> list = userInfoDao.getTecManInnovByAchiName(tTecManInnov.getAchiName(),
					user.getBaseOrgId());
			if (list != null && list.size() > 0) {
				return "该成果名称已存在，请在填写名称时选择下拉项进行编辑";
			}
			tTecManInnov.setCreaterId(user.getFax());
			tTecManInnov.setCreaterName(user.getName());
			tTecManInnov.setOrgId(user.getBaseOrgId());// 单位ID
			tTecManInnov.setOrignalId(tTecManInnov.getId());
			tTecManInnov.setPrimitiveId(tTecManInnov.getId());
			tTecManInnov.setBusinessTypeId(t_tec_man_innov);
			tTecManInnov.setDelSign(0);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				tTecManInnov.setIsValid(0);// 有效
				tTecManInnov.setFlowStatus(1);// 不要审批，默认通过
			} else {
				tTecManInnov.setIsValid(1);// 无效
				tTecManInnov.setFlowStatus(0);// 要审批

				// 添加流程-add by yangwang 20200803
				/*
				 * //先删除之前的审批流程
				 * //updateWorkFlowDataByPrimitiveId(tTecManInnov.getPrimitiveId());
				 * addWorkFlowData(tTecManInnov.getId(),tTecManInnov.getPrimitiveId(),
				 * tTecManInnov.getAuditErpNo(),t_tec_man_innov,user.getFax(),dealRoleCode);
				 */
//				workFlowAntService.addWorkFlow(user, t_tec_man_innov, tTecManInnov.getId(), null, null);
			}
			userInfoDao.addTecManInnov(tTecManInnov);
			addPartRank(ranks, tTecManInnov.getId(), "16");
			// 新增插入操作记录
			addRecordLogData(tTecManInnov.getId(), user, "0");
			// 删除草稿箱数据
			draftsService.deleteMes(tTecManInnov.getId(), "t_tec_man_innov_drafts");
			// 删除草稿箱列表数据
			draftsService.deleteDraftsListByBusinessId(tTecManInnov.getId());
			// 插入工作流
			if (!(("2").equals(user.getRemark()) || ("3").equals(user.getRemark()))) {// 非管理员
				workFlowAntService.addWorkFlow(user, t_tec_man_innov, tTecManInnov.getId(), null, null);
			}
		} else if (("1").equals(tTecManInnov.getIsAdd()) || ("2").equals(tTecManInnov.getIsAdd())) {
			//待审核可编辑-xyy
			/*if ("1".equals(tTecManInnov.getIsAdd())) {
				List<TTecManInnov> tTecManInnovs = getReadyTecManInnovById(tTecManInnov.getId());
				if (tTecManInnovs != null && tTecManInnovs.size() > 0) {
					return "当前数据已经存在待审核状态";
				}
			}*/
			// 防止数据直接从数据库维护进去，business_type_id为空，再次编辑的时候还是为空
			tTecManInnov.setBusinessTypeId(t_tec_man_innov);
			// 日志记录--获取原始业务数据
			String orignalId = "";
			if (!(StringUtil.isNullOrEmpty(tTecManInnov.getProgressCheckId()))) {// 如果是进度查看里的编辑
				orignalId = tTecManInnov.getProgressCheckId();
			} else {
				orignalId = tTecManInnov.getOrignalId();
			}
			TTecManInnov oldTTecManInnov = getTecManInnovByIdForRecord(orignalId);
			//待审核编辑不新增流程-xyy
			List<TTecManInnov> tTecManInnovs = getReadyTecManInnovById(tTecManInnov.getOrignalId());
			if ("1".equals(tTecManInnov.getIsAdd()) && tTecManInnovs != null && tTecManInnovs.size() > 0) {
				tTecManInnov.setId(tTecManInnov.getOrignalId());
				workFlowProcessService.updateTTecManInnov(tTecManInnov, user);
				// 参与人员修改
				updatePartRankData(tTecManInnov.getId(), ranks, "16");
			}else {
				if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
					tTecManInnov.setFlowStatus(1);
					workFlowProcessService.updateTTecManInnov(tTecManInnov, user);
					// 参与人员修改
					updatePartRankData(tTecManInnov.getId(), ranks, "16");
				} else {// 普通用户
					tTecManInnov.setIsValid(1);// 无效
					tTecManInnov.setCreaterId(user.getFax());
					tTecManInnov.setCreaterName(user.getName());
					tTecManInnov.setOrgId(user.getBaseOrgId());
					tTecManInnov.setFlowStatus(0);// 要审批
//				tTecManInnov.setOrignalId(tTecManInnov.getId());
//				tTecManInnov.setId(IdGen.uuid());
					// 参与人员修改
					addPartRank(ranks, tTecManInnov.getId(), "16");
					userInfoDao.addTecManInnov(tTecManInnov);

					// 添加流程-add by yangwang 20200803
					/*
					 * //先删除之前的审批流程 updateWorkFlowDataByPrimitiveId(tTecManInnov.getPrimitiveId());
					 * addWorkFlowData(tTecManInnov.getId(),tTecManInnov.getPrimitiveId(),
					 * tTecManInnov.getAuditErpNo(),t_tec_man_innov,user.getFax(),dealRoleCode);
					 */
					workFlowAntService.addWorkFlow(user, t_tec_man_innov, tTecManInnov.getId(), null, null);
				}
			}

			// 修改插入操作记录
//			addRecordLogData(tTecManInnov.getPrimitiveId(),user,"2");
			oldTTecManInnov.setAwardLevel(
					SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb", oldTTecManInnov.getAwardLevel()));// 获奖级别
			oldTTecManInnov.setAwardGrade(
					SysDictionaryUtil.getNameByValueForDefault("JygexinQcDj", oldTTecManInnov.getAwardGrade()));// 奖项等级
			oldTTecManInnov.setAchiType(
					SysDictionaryUtil.getNameByValueForDefault("KjglAchiveType", oldTTecManInnov.getAchiType()));// 成果类别
			tTecManInnov.setAwardLevel(
					SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb", tTecManInnov.getAwardLevel()));// 获奖级别
			tTecManInnov.setAwardGrade(
					SysDictionaryUtil.getNameByValueForDefault("JygexinQcDj", tTecManInnov.getAwardGrade()));// 奖项等级
			tTecManInnov.setAchiType(
					SysDictionaryUtil.getNameByValueForDefault("KjglAchiveType", tTecManInnov.getAchiType()));// 成果类别
			addRecordLogInfo(tTecManInnov, oldTTecManInnov, user, tTecManInnov.getPrimitiveId(), tTecManInnov.getId(),
					"2");
		}
		return null;
	}

	@Override
	public TTecManInnov getTecManInnovByIdForRecord(String id) {
		TTecManInnov tTecManInnov = userInfoDao.getTecManInnovByIdForRecord(id);
		if (tTecManInnov != null) {
			List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(new HashSet<String>() {
				{
					add(id);
				}
			}, "16");
			tTecManInnov.settPartRankList(tPartRankList);
		}
		return tTecManInnov;
	}

	@Override
	public TTecManInnovVo getTecManInnovById(String id) {
		TTecManInnovVo tTecManInnovVo = userInfoDao.getTecManInnovById(id);
		if (tTecManInnovVo != null) {
			List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(new HashSet<String>() {
				{
					add(id);
				}
			}, "16");
			tTecManInnovVo.settPartRankList(tPartRankList);
		}
		return tTecManInnovVo;
	}

	@Override
	public List<TTecManInnovVo> getTecManInnovByErpNo(String erpNo) {

		List<TTecManInnovVo> tTecManInnovVos = userInfoDao.getTecManInnovByErpNo(erpNo);

		if (tTecManInnovVos.isEmpty()) {
			return tTecManInnovVos;
		}
		Set<String> ids = new HashSet<>();
		tTecManInnovVos.forEach(i -> ids.add(i.getId()));
		List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(ids, "16");
		if (!tPartRankList.isEmpty()) {
			for (TTecManInnovVo tTecManInnovVo : tTecManInnovVos) {
				List<TPartRank> tPartRankListVo = new ArrayList<>();
				for (TPartRank tPartRank : tPartRankList) {
					if (tTecManInnovVo.getId().equals(tPartRank.getItemId())) {
						tPartRankListVo.add(tPartRank);
					}
				}

				tTecManInnovVo.settPartRankList(tPartRankListVo);
			}
		}

		return tTecManInnovVos;
	}

	@Override
	public void findPageTecManInnovByCondi(Page<TTecManInnovVo> page, TTecManInnov tTecManInnov) {
		userInfoDao.findPageTecManInnovByCondi(page, tTecManInnov);
		if (!page.getResult().isEmpty()) {
			List<TTecManInnovVo> tTecManInnovVos = page.getResult();
			Set<String> ids = new HashSet<>();
			tTecManInnovVos.forEach(i -> ids.add(i.getId()));
			List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(ids, "16");
			if (!tPartRankList.isEmpty()) {
				for (TTecManInnovVo tTecManInnovVo : tTecManInnovVos) {
					List<TPartRank> tPartRankListVo = new ArrayList<>();
					for (TPartRank tPartRank : tPartRankList) {
						if (tTecManInnovVo.getId().equals(tPartRank.getItemId())) {
							tPartRankListVo.add(tPartRank);
						}
					}

					tTecManInnovVo.settPartRankList(tPartRankListVo);
				}
			}
		}
	}

	/**
	 * 个人荣誉
	 *
	 * @param tHonorInfo
	 * @param user
	 * @throws Exception
	 */
	@Override
	@Transactional
	public String addHonorInfo(THonorInfo tHonorInfo, User user) throws Exception {
		tHonorInfo.setUpdaterId(user.getFax());
		tHonorInfo.setUpdaterName(user.getName());
		if (tHonorInfo.getIsAdd().equals("0")) {// 新增
			tHonorInfo.setCreaterId(user.getFax());
			tHonorInfo.setCreaterName(user.getName());
			tHonorInfo.setOrgId(user.getBaseOrgId());// 单位ID
			tHonorInfo.setOrignalId(tHonorInfo.getId());
			tHonorInfo.setPrimitiveId(tHonorInfo.getId());
			tHonorInfo.setBusinessTypeId(t_honor_info);
			tHonorInfo.setDelSign(0);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				tHonorInfo.setIsValid(0);// 有效
				tHonorInfo.setFlowStatus(1);// 不要审批，默认通过
			} else {
				tHonorInfo.setIsValid(1);// 无效
				tHonorInfo.setFlowStatus(0);// 要审批

				// 添加流程-add by yangwang 20200803
				/*
				 * //先删除之前的审批流程 //updateWorkFlowDataByPrimitiveId(tHonorInfo.getPrimitiveId());
				 * addWorkFlowData(tHonorInfo.getId(),tHonorInfo.getPrimitiveId(),tHonorInfo.
				 * getAuditErpNo(),t_honor_info,user.getFax(),dealRoleCode);
				 */
//				workFlowAntService.addWorkFlow(user, t_honor_info, tHonorInfo.getId(), null, null);
			}
			userInfoDao.addHonorInfo(tHonorInfo);
			// 新增插入操作记录
			addRecordLogData(tHonorInfo.getId(), user, "0");
			// 删除草稿箱数据
			draftsService.deleteMes(tHonorInfo.getId(), "t_honor_info_drafts");
			// 删除草稿箱列表数据
			draftsService.deleteDraftsListByBusinessId(tHonorInfo.getId());
			// 插入工作流
			if (!(("2").equals(user.getRemark()) || ("3").equals(user.getRemark()))) {// 非管理员
				workFlowAntService.addWorkFlow(user, t_honor_info, tHonorInfo.getId(), null, null);
			}
		} else {// 修改
			List<TSalaryBusinessBind> list = userInfoDao.selectSalaryBusinessBind(t_honor_info,tHonorInfo.getOrignalId());
			if(!CollectionUtils.isEmpty(list)){
				return "当前数据已用于薪档申报，不可修改！";
			}
			//待审核可编辑-xyy
			/*if ("1".equals(tHonorInfo.getIsAdd())) {
				List<THonorInfo> tHonorInfos = getReadyHonorInfoById(tHonorInfo.getId());
				if (tHonorInfos != null && tHonorInfos.size() > 0) {
					return "当前数据已经存在待审核状态";
				}
			}*/
			// 防止数据直接从数据库维护进去，business_type_id为空，再次编辑的时候还是为空
			tHonorInfo.setBusinessTypeId(t_honor_info);
			// 日志记录--获取原始业务数据
			String orignalId = "";
			if (!(StringUtil.isNullOrEmpty(tHonorInfo.getProgressCheckId()))) {// 如果是进度查看里的编辑
				orignalId = tHonorInfo.getProgressCheckId();
			} else {
				orignalId = tHonorInfo.getOrignalId();
			}
			THonorInfo oldTHonorInfo = userInfoDao.getHonorInfoById(orignalId);
			//待审核编辑不新增流程-xyy
			List<THonorInfo> tHonorInfos = getReadyHonorInfoById(tHonorInfo.getOrignalId());
			if ("1".equals(tHonorInfo.getIsAdd()) && tHonorInfos != null && tHonorInfos.size() > 0) {
				tHonorInfo.setId(tHonorInfo.getOrignalId());
				workFlowProcessService.updateTHonorInfo(tHonorInfo, user);
			}else{
				if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
					tHonorInfo.setFlowStatus(1);
					workFlowProcessService.updateTHonorInfo(tHonorInfo, user);
				} else {// 普通用户
					tHonorInfo.setIsValid(1);// 无效
					tHonorInfo.setCreaterId(user.getFax());
					tHonorInfo.setCreaterName(user.getName());
					tHonorInfo.setOrgId(user.getBaseOrgId());
					tHonorInfo.setFlowStatus(0);// 要审批
//				tHonorInfo.setOrignalId(tHonorInfo.getId());
//				tHonorInfo.setId(IdGen.uuid());
					userInfoDao.addHonorInfo(tHonorInfo);

					// 添加流程-add by yangwang 20200803
					/*
					 * //先删除之前的审批流程 updateWorkFlowDataByPrimitiveId(tHonorInfo.getPrimitiveId());
					 * addWorkFlowData(tHonorInfo.getId(),tHonorInfo.getPrimitiveId(),tHonorInfo.
					 * getAuditErpNo(),t_honor_info,user.getFax(),dealRoleCode);
					 */
					workFlowAntService.addWorkFlow(user, t_honor_info, tHonorInfo.getId(), null, null);
				}
			}

			// 修改插入操作记录
//			addRecordLogData(tHonorInfo.getPrimitiveId(),user,"2");
			oldTHonorInfo.setHonorLevel(
					SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb", oldTHonorInfo.getHonorLevel()));
			oldTHonorInfo.setHonorType(
					SysDictionaryUtil.getNameByValueForDefault("RuYuLeiBie", oldTHonorInfo.getHonorType()));
			tHonorInfo.setHonorLevel(
					SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb", tHonorInfo.getHonorLevel()));
			tHonorInfo
					.setHonorType(SysDictionaryUtil.getNameByValueForDefault("RuYuLeiBie", tHonorInfo.getHonorType()));
			addRecordLogInfo(tHonorInfo, oldTHonorInfo, user, tHonorInfo.getPrimitiveId(), tHonorInfo.getId(), "2");
		}
		return null;
	}

	@Override
	public THonorInfo getHonorInfoById(String id) {
		return userInfoDao.getHonorInfoById(id);
	}

	@Override
	public List<THonorInfo> getHonnorInfoByErpNo(String erpNo) {
		return userInfoDao.getHonnorInfoByErpNo(erpNo);
	}

	@Override
	public void findPageHonorInfoByCondi(Page<THonorInfo> page, THonorInfo tHonorInfo) {
		userInfoDao.findPageHonorInfoByCondi(page, tHonorInfo);
	}

	/**
	 * 工作经历
	 *
	 * @param tWorkExpInfo
	 * @param user
	 * @throws Exception
	 */
	@Override
	@Transactional
	public String addWorkExpInfo(TWorkExpInfo tWorkExpInfo, User user) throws Exception {
		tWorkExpInfo.setUpdaterId(user.getFax());
		tWorkExpInfo.setUpdaterName(user.getName());
		if (tWorkExpInfo.getIsAdd().equals("0")) {// 新增
			tWorkExpInfo.setCreaterId(user.getFax());
			tWorkExpInfo.setCreaterName(user.getName());
			tWorkExpInfo.setOrgId(user.getBaseOrgId());// 单位ID
			tWorkExpInfo.setOrignalId(tWorkExpInfo.getId());
			tWorkExpInfo.setPrimitiveId(tWorkExpInfo.getId());
			tWorkExpInfo.setBusinessTypeId(t_work_exp_info);
			tWorkExpInfo.setDelSign(0);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				tWorkExpInfo.setIsValid(0);// 有效
				tWorkExpInfo.setFlowStatus(1);// 不要审批，默认通过
			} else {
				tWorkExpInfo.setIsValid(1);// 无效
				tWorkExpInfo.setFlowStatus(0);// 要审批

				// 添加流程-add by yangwang 20200803
				/*
				 * //先删除之前的审批流程
				 * //updateWorkFlowDataByPrimitiveId(tWorkExpInfo.getPrimitiveId());
				 * addWorkFlowData(tWorkExpInfo.getId(),tWorkExpInfo.getPrimitiveId(),
				 * tWorkExpInfo.getAuditErpNo(),t_work_exp_info,user.getFax(),dealRoleCode);
				 */
//				workFlowAntService.addWorkFlow(user, t_work_exp_info, tWorkExpInfo.getId(), null, null);
			}
			userInfoDao.addWorkExpInfo(tWorkExpInfo);
			// 新增插入操作记录
			addRecordLogData(tWorkExpInfo.getId(), user, "0");
			// 删除草稿箱数据
			draftsService.deleteMes(tWorkExpInfo.getId(), "t_work_exp_info_drafts");
			// 删除草稿箱列表数据
			draftsService.deleteDraftsListByBusinessId(tWorkExpInfo.getId());
			// 插入工作流
			if (!(("2").equals(user.getRemark()) || ("3").equals(user.getRemark()))) {// 非管理员
				workFlowAntService.addWorkFlow(user, t_work_exp_info, tWorkExpInfo.getId(), null, null);
			}
		} else {// 修改
			//待审核可编辑-xyy
			/*if ("1".equals(tWorkExpInfo.getIsAdd())) {
				List<TWorkExpInfo> tWorkExpInfos = getReadyWorkExpInfoById(tWorkExpInfo.getId());
				if (tWorkExpInfos != null && tWorkExpInfos.size() > 0) {
					return "当前数据已经存在待审核状态";
				}
			}*/
			// 防止数据直接从数据库维护进去，business_type_id为空，再次编辑的时候还是为空
			tWorkExpInfo.setBusinessTypeId(t_work_exp_info);
			// 日志记录--获取原始业务数据
			String orignalId = "";
			if (!(StringUtil.isNullOrEmpty(tWorkExpInfo.getProgressCheckId()))) {// 如果是进度查看里的编辑
				orignalId = tWorkExpInfo.getProgressCheckId();
			} else {
				orignalId = tWorkExpInfo.getOrignalId();
			}
			TWorkExpInfo oldTWorkExpInfo = userInfoDao.getWorkExpInfoById(orignalId);
			//待审核编辑不新增流程-xyy
			List<TWorkExpInfo> tWorkExpInfos = getReadyWorkExpInfoById(tWorkExpInfo.getOrignalId());
			if ("1".equals(tWorkExpInfo.getIsAdd()) && tWorkExpInfos != null && tWorkExpInfos.size() > 0) {
				tWorkExpInfo.setId(tWorkExpInfo.getOrignalId());
				workFlowProcessService.updateTWorkExpInfo(tWorkExpInfo, user);
			}else {
				if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
					tWorkExpInfo.setFlowStatus(1);
					workFlowProcessService.updateTWorkExpInfo(tWorkExpInfo, user);
				} else {// 普通用户
					tWorkExpInfo.setIsValid(1);// 无效
					tWorkExpInfo.setCreaterId(user.getFax());
					tWorkExpInfo.setCreaterName(user.getName());
					tWorkExpInfo.setOrgId(user.getBaseOrgId());
					tWorkExpInfo.setFlowStatus(0);// 要审批
//				tWorkExpInfo.setOrignalId(tWorkExpInfo.getId());
//				tWorkExpInfo.setId(IdGen.uuid());
					userInfoDao.addWorkExpInfo(tWorkExpInfo);

					// 添加流程-add by yangwang 20200803
					/*
					 * //先删除之前的审批流程 updateWorkFlowDataByPrimitiveId(tWorkExpInfo.getPrimitiveId());
					 * addWorkFlowData(tWorkExpInfo.getId(),tWorkExpInfo.getPrimitiveId(),
					 * tWorkExpInfo.getAuditErpNo(),t_work_exp_info,user.getFax(),dealRoleCode);
					 */
					workFlowAntService.addWorkFlow(user, t_work_exp_info, tWorkExpInfo.getId(), null, null);
				}
			}

			// 修改插入操作记录
//			addRecordLogData(tWorkExpInfo.getPrimitiveId(),user,"2");
			oldTWorkExpInfo.setRank(SysDictionaryUtil.getNameByValueForDefault("DutyLevel", oldTWorkExpInfo.getRank()));// 级别
			oldTWorkExpInfo.setPostType(
					SysDictionaryUtil.getNameByValueForDefault("PostCategory", oldTWorkExpInfo.getPostType()));// 岗位类别
			tWorkExpInfo.setRank(SysDictionaryUtil.getNameByValueForDefault("DutyLevel", tWorkExpInfo.getRank()));// 级别
			tWorkExpInfo.setPostType(
					SysDictionaryUtil.getNameByValueForDefault("PostCategory", tWorkExpInfo.getPostType()));// 岗位类别
			addRecordLogInfo(tWorkExpInfo, oldTWorkExpInfo, user, tWorkExpInfo.getPrimitiveId(), tWorkExpInfo.getId(),
					"2");
		}
		return null;
	}

	@Override
	public TWorkExpInfo getWorkExpInfoById(String id) {
		return userInfoDao.getWorkExpInfoById(id);
	}

	@Override
	public List<TWorkExpInfo> getWorkExpInfoByErpNo(String erpNo) {
		return userInfoDao.getWorkExpInfoByErpNo(erpNo);
	}

	@Override
	public void findPageWorkExpInfoByCondi(Page<TWorkExpInfo> page, TWorkExpInfo tWorkExpInfo) {
		userInfoDao.findPageWorkExpInfoByCondi(page, tWorkExpInfo);
	}

	/**
	 * 教育培训及授课
	 *
	 * @param tContiStudyInfo
	 * @param user
	 * @throws Exception
	 */
	@Override
	@Transactional
	public String addContiStudyInfo(TContiStudyInfo tContiStudyInfo, User user) throws Exception {
		tContiStudyInfo.setUpdaterId(user.getFax());
		tContiStudyInfo.setUpdaterName(user.getName());
		if (tContiStudyInfo.getIsAdd().equals("0")) {// 新增
			tContiStudyInfo.setCreaterId(user.getFax());
			tContiStudyInfo.setCreaterName(user.getName());
			tContiStudyInfo.setOrgId(user.getBaseOrgId());// 单位ID
			tContiStudyInfo.setOrignalId(tContiStudyInfo.getId());
			tContiStudyInfo.setPrimitiveId(tContiStudyInfo.getId());
			tContiStudyInfo.setBusinessTypeId(t_conti_study_info);
			tContiStudyInfo.setDelSign(0);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				tContiStudyInfo.setIsValid(0);// 有效
				tContiStudyInfo.setFlowStatus(1);// 不要审批，默认通过
			} else {
				tContiStudyInfo.setIsValid(1);// 无效
				tContiStudyInfo.setFlowStatus(0);// 要审批

				// 添加流程-add by yangwang 20200803
				/*
				 * //先删除之前的审批流程
				 * //updateWorkFlowDataByPrimitiveId(tContiStudyInfo.getPrimitiveId());
				 * addWorkFlowData(tContiStudyInfo.getId(),tContiStudyInfo.getPrimitiveId(),
				 * tContiStudyInfo.getAuditErpNo(),t_conti_study_info,user.getFax(),dealRoleCode
				 * );
				 */
//				workFlowAntService.addWorkFlow(user, t_conti_study_info, tContiStudyInfo.getId(), null, null);
			}
			userInfoDao.addContiStudyInfo(tContiStudyInfo);
			// 新增插入操作记录
			addRecordLogData(tContiStudyInfo.getId(), user, "0");
			// 删除草稿箱数据
			draftsService.deleteMes(tContiStudyInfo.getId(), "t_conti_study_info_drafts");
			// 删除草稿箱列表数据
			draftsService.deleteDraftsListByBusinessId(tContiStudyInfo.getId());
			// 插入工作流
			if (!(("2").equals(user.getRemark()) || ("3").equals(user.getRemark()))) {// 非管理员
				workFlowAntService.addWorkFlow(user, t_conti_study_info, tContiStudyInfo.getId(), null, null);
			}
		} else {// 修改
			List<TSalaryBusinessBind> list = userInfoDao.selectSalaryBusinessBind(t_conti_study_info,tContiStudyInfo.getOrignalId());
			if(!CollectionUtils.isEmpty(list)){
				return "当前数据已用于薪档申报，不可修改！";
			}
			//待审核可编辑-xyy
			/*if ("1".equals(tContiStudyInfo.getIsAdd())) {
				List<TContiStudyInfo> tContiStudyInfos = getReadyContiStudyInfoById(tContiStudyInfo.getId());
				if (tContiStudyInfos != null && tContiStudyInfos.size() > 0) {
					return "当前数据已经存在待审核状态";
				}
			}*/
			// 防止数据直接从数据库维护进去，business_type_id为空，再次编辑的时候还是为空
			tContiStudyInfo.setBusinessTypeId(t_conti_study_info);
			// 日志记录--获取原始业务数据
			String orignalId = "";
			if (!(StringUtil.isNullOrEmpty(tContiStudyInfo.getProgressCheckId()))) {// 如果是进度查看里的编辑
				orignalId = tContiStudyInfo.getProgressCheckId();
			} else {
				orignalId = tContiStudyInfo.getOrignalId();
			}
			TContiStudyInfo oldTContiStudyInfo = userInfoDao.getContiStudyInfoById(orignalId);
			//待审核编辑不新增流程-xyy
			List<TContiStudyInfo> tContiStudyInfos = getReadyContiStudyInfoById(tContiStudyInfo.getOrignalId());
			if ("1".equals(tContiStudyInfo.getIsAdd()) && tContiStudyInfos != null && tContiStudyInfos.size() > 0) {
				tContiStudyInfo.setId(tContiStudyInfo.getOrignalId());
				workFlowProcessService.updateTContiStudyInfo(tContiStudyInfo, user);
			}else {
				if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
					tContiStudyInfo.setFlowStatus(1);
					workFlowProcessService.updateTContiStudyInfo(tContiStudyInfo, user);
				} else {// 普通用户
					tContiStudyInfo.setIsValid(1);// 无效
					tContiStudyInfo.setCreaterId(user.getFax());
					tContiStudyInfo.setCreaterName(user.getName());
					tContiStudyInfo.setOrgId(user.getBaseOrgId());
					tContiStudyInfo.setFlowStatus(0);// 要审批
//				tContiStudyInfo.setOrignalId(tContiStudyInfo.getId());
//				tContiStudyInfo.setId(IdGen.uuid());
					userInfoDao.addContiStudyInfo(tContiStudyInfo);

					// 添加流程-add by yangwang 20200803
					/*
					 * //先删除之前的审批流程
					 * updateWorkFlowDataByPrimitiveId(tContiStudyInfo.getPrimitiveId());
					 * addWorkFlowData(tContiStudyInfo.getId(),tContiStudyInfo.getPrimitiveId(),
					 * tContiStudyInfo.getAuditErpNo(),t_conti_study_info,user.getFax(),dealRoleCode
					 * );
					 */
					workFlowAntService.addWorkFlow(user, t_conti_study_info, tContiStudyInfo.getId(), null, null);
				}
			}

			// 修改插入操作记录
//			addRecordLogData(tContiStudyInfo.getPrimitiveId(),user,"2");
			oldTContiStudyInfo.setType(
					SysDictionaryUtil.getNameByValueForDefault("PeixunshoukeType", oldTContiStudyInfo.getType()));// 类别
			tContiStudyInfo
					.setType(SysDictionaryUtil.getNameByValueForDefault("PeixunshoukeType", tContiStudyInfo.getType()));// 类别
			addRecordLogInfo(tContiStudyInfo, oldTContiStudyInfo, user, tContiStudyInfo.getPrimitiveId(),
					tContiStudyInfo.getId(), "2");
		}
		return null;
	}

	@Override
	public TContiStudyInfo getContiStudyInfoById(String id) {
		return userInfoDao.getContiStudyInfoById(id);
	}

	@Override
	public List<TContiStudyInfo> getContiStudyInfoByErpNo(String erpNo) {
		return userInfoDao.getContiStudyInfoByErpNo(erpNo);
	}

	@Override
	public void findPageContiStudyInfoByCondi(Page<TContiStudyInfo> page, TContiStudyInfo tContiStudyInfo) {
		userInfoDao.findPageContiStudyInfoByCondi(page, tContiStudyInfo);
	}

	/**
	 * 师带徒信息
	 *
	 * @param tSdtTutorPrentInfo
	 * @param user
	 * @throws Exception
	 */
	@Override
	@Transactional
	public String addSdtTutorPrentInfo(TSdtTutorPrentInfo tSdtTutorPrentInfo, User user) throws Exception {
		tSdtTutorPrentInfo.setUpdaterId(user.getFax());
		tSdtTutorPrentInfo.setUpdaterName(user.getName());
		List<TSdtPrentInfo> prentList = tSdtTutorPrentInfo.gettSdtPrentInfo();
		// 根据erp_no过滤重复选中的人
		List<TSdtPrentInfo> prents = prentList.stream()
				.collect(Collectors.collectingAndThen(
						Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(TSdtPrentInfo::getErpNo))),
						ArrayList::new));
		if (tSdtTutorPrentInfo.getIsAdd().equals("0")) {// 新增
			tSdtTutorPrentInfo.setCreaterId(user.getFax());
			tSdtTutorPrentInfo.setCreaterName(user.getName());
			tSdtTutorPrentInfo.setOrgId(user.getBaseOrgId());// 单位ID
			tSdtTutorPrentInfo.setOrignalId(tSdtTutorPrentInfo.getId());
			tSdtTutorPrentInfo.setPrimitiveId(tSdtTutorPrentInfo.getId());
			tSdtTutorPrentInfo.setBusinessTypeId(t_sdt_tutor_prent_info);
			tSdtTutorPrentInfo.setDelSign(0);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				tSdtTutorPrentInfo.setIsValid(0);// 有效
				tSdtTutorPrentInfo.setFlowStatus(1);// 不要审批，默认通过
			} else {
				tSdtTutorPrentInfo.setIsValid(1);// 无效
				tSdtTutorPrentInfo.setFlowStatus(0);// 要审批

				// 添加流程-add by yangwang 20200803
				/*
				 * //先删除之前的审批流程
				 * //updateWorkFlowDataByPrimitiveId(tSdtTutorPrentInfo.getPrimitiveId());
				 * addWorkFlowData(tSdtTutorPrentInfo.getId(),tSdtTutorPrentInfo.getPrimitiveId(
				 * ),tSdtTutorPrentInfo.getAuditErpNo(),t_sdt_tutor_prent_info,user.getFax(),
				 * dealRoleCode);
				 */
//				workFlowAntService.addWorkFlow(user, t_sdt_tutor_prent_info, tSdtTutorPrentInfo.getId(), null, null);
			}
			userInfoDao.addSdtTutorPrentInfo(tSdtTutorPrentInfo);
			// 徒弟新增
//			if(prents.size()>0){
//				prents.forEach(p ->{
//					p.setSdtId(tSdtTutorPrentInfo.getId());
//					p.setId(IdGen.uuid());
//					userInfoDao.addSdtPrentInfo(p);
//					//所获奖项添加
//					List<TSdtAward> tSdtAwards = p.gettSdtAwardList();
//					if(tSdtAwards != null && tSdtAwards.size()>0){
//						tSdtAwards.forEach(t ->{
//							t.setItemId(p.getId());
//							t.setCreaterId(user.getFax());
//							t.setCreaterName(user.getName());
//							t.setUpdaterId(user.getFax());
//							t.setUpdaterName(user.getName());
//							userInfoDao.addSdtAwardInfo(t);
//						});
//					}
//				});
//			}
			// 新增插入操作记录
			addRecordLogData(tSdtTutorPrentInfo.getId(), user, "0");
			// 删除草稿箱数据
			draftsService.deleteMes(tSdtTutorPrentInfo.getId(), "t_sdt_tutor_prent_info_drafts");
			// 删除草稿箱列表数据
			draftsService.deleteDraftsListByBusinessId(tSdtTutorPrentInfo.getId());
			// 插入工作流
			if (!(("2").equals(user.getRemark()) || ("3").equals(user.getRemark()))) {// 非管理员
				workFlowAntService.addWorkFlow(user, t_sdt_tutor_prent_info, tSdtTutorPrentInfo.getId(), null, null);
			}
		} else {// 修改
			List<TSalaryBusinessBind> list = userInfoDao.selectSalaryBusinessBind(t_sdt_tutor_prent_info,tSdtTutorPrentInfo.getOrignalId());
			if(!CollectionUtils.isEmpty(list)){
				return "当前数据已用于薪档申报，不可修改！";
			}
			//待审核可编辑-xyy
			/*if ("1".equals(tSdtTutorPrentInfo.getIsAdd())) {
				List<TSdtTutorPrentInfo> tSdtTutorPrentInfos = getReadySdtTutorPrentInfoById(
						tSdtTutorPrentInfo.getId());
				if (tSdtTutorPrentInfos != null && tSdtTutorPrentInfos.size() > 0) {
					return "当前数据已经存在待审核状态";
				}
			}*/
			// 防止数据直接从数据库维护进去，business_type_id为空，再次编辑的时候还是为空
			tSdtTutorPrentInfo.setBusinessTypeId(t_sdt_tutor_prent_info);
			// 日志记录--获取原始业务数据
			String orignalId = "";
			if (!(StringUtil.isNullOrEmpty(tSdtTutorPrentInfo.getProgressCheckId()))) {// 如果是进度查看里的编辑
				orignalId = tSdtTutorPrentInfo.getProgressCheckId();
			} else {
				orignalId = tSdtTutorPrentInfo.getOrignalId();
			}
			TSdtTutorPrentInfo oldTSdtTutorPrentInfo = getSdtTutorPrentInfoById(orignalId);
			//待审核编辑不新增流程-xyy
			List<TSdtTutorPrentInfo> tSdtTutorPrentInfos = getReadySdtTutorPrentInfoById(
					tSdtTutorPrentInfo.getOrignalId());
			if ("1".equals(tSdtTutorPrentInfo.getIsAdd()) && tSdtTutorPrentInfos != null && tSdtTutorPrentInfos.size() > 0) {
				tSdtTutorPrentInfo.setId(tSdtTutorPrentInfo.getOrignalId());
				workFlowProcessService.updateTSdtTutorPrentInfo(tSdtTutorPrentInfo, user);
				// 徒弟修改
				// 先删除徒弟所获奖项信息
				List<TSdtPrentInfo> prentInfos = userInfoDao.getTSdtPrentInfoListById(tSdtTutorPrentInfo.getId());
				if (prentInfos != null && prentInfos.size() > 0) {
					prentInfos.forEach(p -> {
						humanDataDao.deleteTSdtAwardBySdtTdId(p.getId());
					});
				}
				// 再删除徒弟信息
				humanDataDao.deleteTSdtPrentInfoByCondition(null, tSdtTutorPrentInfo.getId());
			}else{
				if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
					tSdtTutorPrentInfo.setFlowStatus(1);
					workFlowProcessService.updateTSdtTutorPrentInfo(tSdtTutorPrentInfo, user);
					// 徒弟修改
					// 先删除徒弟所获奖项信息
					List<TSdtPrentInfo> prentInfos = userInfoDao.getTSdtPrentInfoListById(tSdtTutorPrentInfo.getId());
					if (prentInfos != null && prentInfos.size() > 0) {
						prentInfos.forEach(p -> {
							humanDataDao.deleteTSdtAwardBySdtTdId(p.getId());
						});
					}
					// 再删除徒弟信息
					humanDataDao.deleteTSdtPrentInfoByCondition(null, tSdtTutorPrentInfo.getId());
					// 再插入
//				if(prents.size() > 0){
//					prents.forEach(p ->{
//						p.setId(IdGen.uuid());
//						p.setSdtId(tSdtTutorPrentInfo.getId());
//						p.setCreaterId(user.getFax());
//						p.setCreaterName(user.getName());
//						p.setDelSign(0);
//						userInfoDao.addSdtPrentInfo(p);
//						List<TSdtAward> tSdtAwards = p.gettSdtAwardList();
//						if(tSdtAwards != null && tSdtAwards.size()>0){
//							tSdtAwards.forEach(t ->{
//								t.setItemId(p.getId());
//								t.setCreaterId(user.getFax());
//								t.setCreaterName(user.getName());
//								t.setUpdaterId(user.getFax());
//								t.setUpdaterName(user.getName());
//								userInfoDao.addSdtAwardInfo(t);
//							});
//						}
//					});
//				}
				} else {// 普通用户
					tSdtTutorPrentInfo.setIsValid(1);// 无效
					tSdtTutorPrentInfo.setCreaterId(user.getFax());
					tSdtTutorPrentInfo.setCreaterName(user.getName());
					tSdtTutorPrentInfo.setOrgId(user.getBaseOrgId());
					tSdtTutorPrentInfo.setFlowStatus(0);// 要审批
//				tSdtTutorPrentInfo.setOrignalId(tSdtTutorPrentInfo.getId());
//				tSdtTutorPrentInfo.setId(IdGen.uuid());
					// 徒弟
//				if(prents.size()>0){
//					prents.forEach(p ->{
//						p.setSdtId(tSdtTutorPrentInfo.getId());
//						p.setId(IdGen.uuid());
//						userInfoDao.addSdtPrentInfo(p);
//						//徒弟所获奖项
//						List<TSdtAward> tSdtAwards = p.gettSdtAwardList();
//						if(tSdtAwards != null && tSdtAwards.size()>0){
//							tSdtAwards.forEach(t ->{
//								t.setItemId(p.getId());
//								t.setCreaterId(user.getFax());
//								t.setCreaterName(user.getName());
//								t.setUpdaterId(user.getFax());
//								t.setUpdaterName(user.getName());
//								userInfoDao.addSdtAwardInfo(t);
//							});
//						}
//					});
//				}
					userInfoDao.addSdtTutorPrentInfo(tSdtTutorPrentInfo);

					// 添加流程-add by yangwang 20200803
					/*
					 * //先删除之前的审批流程
					 * updateWorkFlowDataByPrimitiveId(tSdtTutorPrentInfo.getPrimitiveId());
					 * addWorkFlowData(tSdtTutorPrentInfo.getId(),tSdtTutorPrentInfo.getPrimitiveId(
					 * ),tSdtTutorPrentInfo.getAuditErpNo(),t_sdt_tutor_prent_info,user.getFax(),
					 * dealRoleCode);
					 */
					workFlowAntService.addWorkFlow(user, t_sdt_tutor_prent_info, tSdtTutorPrentInfo.getId(), null, null);
				}
			}

			// 修改插入操作记录
//			addRecordLogData(tSdtTutorPrentInfo.getPrimitiveId(),user,"2");
			addRecordLogInfo(tSdtTutorPrentInfo, oldTSdtTutorPrentInfo, user, tSdtTutorPrentInfo.getPrimitiveId(),
					tSdtTutorPrentInfo.getId(), "2");
		}
		// 插入徒弟信息及徒弟所获奖项信息，管理员新增、普通人员新增、修改时都是新增；
		// 管理员修改时只是修改，先将原徒弟信息和徒弟所获奖项删除，然后再新增
		if (prents.size() > 0) {
			prents.forEach(p -> {
				p.setId(IdGen.uuid());
				p.setSdtId(tSdtTutorPrentInfo.getId());
				p.setCreaterId(user.getFax());
				p.setCreaterName(user.getName());
				p.setDelSign(0);
				if (StringUtil.isNullOrEmpty(p.getErpNo())) {
					p.setErpNo(p.getUserName());
				}
				userInfoDao.addSdtPrentInfo(p);
				List<TSdtAward> tSdtAwards = p.gettSdtAwardList();
				if (tSdtAwards != null && tSdtAwards.size() > 0) {
					tSdtAwards.forEach(t -> {
						t.setId(IdGen.uuid());
						t.setSdtTdId(p.getId());
						t.setCreaterId(user.getFax());
						t.setCreaterName(user.getName());
						t.setUpdaterId(user.getFax());
						t.setUpdaterName(user.getName());
						userInfoDao.addSdtAwardInfo(t);
					});
				}
			});
		}
		return null;
	}

	@Override
	public TSdtTutorPrentInfo getSdtTutorPrentInfoById(String id) {
		TSdtTutorPrentInfo tSdtTutorPrentInfo = userInfoDao.getSdtTutorPrentInfoById(id);

		if (tSdtTutorPrentInfo != null) {
			List<TSdtPrentInfo> tSdtPrentInfos = userInfoDao.getTSdtPrentInfoByMids(new ArrayList<String>() {
				{
					add(tSdtTutorPrentInfo.getId());
				}
			});
			// 徒弟所获奖项
			if (tSdtPrentInfos != null && tSdtPrentInfos.size() > 0) {
				tSdtPrentInfos.forEach(p -> {
					List<TSdtAward> tSdtAwards = userInfoDao.getSdtAwardBySdtTdId(p.getId());
					p.settSdtAwardList(tSdtAwards);
				});
			}
			tSdtTutorPrentInfo.settSdtPrentInfo(tSdtPrentInfos);
		}
		return tSdtTutorPrentInfo;
	}

	@Override
	public List<TSdtTutorPrentInfo> getSdtTutorPrentInfoByErpNo(String erpNo) {
		List<TSdtTutorPrentInfo> tSdtTutorPrentInfos = userInfoDao.getSdtTutorPrentInfoByErpNo(erpNo);

		if (tSdtTutorPrentInfos.isEmpty()) {
			return tSdtTutorPrentInfos;
		}
		List<String> ids = new ArrayList<>();
		tSdtTutorPrentInfos.forEach(i -> ids.add(i.getId()));
		List<TSdtPrentInfo> tSdtPrentInfoList = userInfoDao.getTSdtPrentInfoByMids(ids);
		if (!tSdtPrentInfoList.isEmpty()) {

			List<String> prentIds = new ArrayList<>();
			tSdtPrentInfoList.forEach(i -> prentIds.add(i.getId()));
			List<TSdtAward> tSdtAwardList = userInfoDao.getTSdtAwardByMids(prentIds);

			for (TSdtTutorPrentInfo tutorPrentInfo : tSdtTutorPrentInfos) {
				List<TSdtPrentInfo> tSdtPrentInfos = new ArrayList<>();
				for (TSdtPrentInfo tSdtPrentInfo : tSdtPrentInfoList) {

					if (!tSdtAwardList.isEmpty()) {
						List<TSdtAward> tSdtAwards = new ArrayList<>();
						for (TSdtAward tSdtAward : tSdtAwardList) {
							if (tSdtAward.getSdtTdId().equals(tSdtPrentInfo.getId())) {
								tSdtAwards.add(tSdtAward);
							}
						}

						tSdtPrentInfo.settSdtAwardList(tSdtAwards);
					}

					if (tutorPrentInfo.getId().equals(tSdtPrentInfo.getSdtId())) {
						tSdtPrentInfos.add(tSdtPrentInfo);
					}
				}

				tutorPrentInfo.settSdtPrentInfo(tSdtPrentInfos);
			}
		}
		return tSdtTutorPrentInfos;
	}

	@Override
	public void findPageSdtTutorPrentInfoByCondi(Page<TSdtTutorPrentInfo> page, TSdtTutorPrentInfo tSdtTutorPrentInfo) {
		userInfoDao.findPageSdtTutorPrentInfoByCondi(page, tSdtTutorPrentInfo);

		if (!page.getResult().isEmpty()) {
			List<TSdtTutorPrentInfo> tSdtTutorPrentInfos = page.getResult();

			List<String> ids = new ArrayList<>();
			tSdtTutorPrentInfos.forEach(i -> ids.add(i.getId()));
			List<TSdtPrentInfo> tSdtPrentInfoList = userInfoDao.getTSdtPrentInfoByMids(ids);

			if (!tSdtPrentInfoList.isEmpty()) {
				List<String> prentIds = new ArrayList<>();
				tSdtPrentInfoList.forEach(i -> prentIds.add(i.getId()));
				List<TSdtAward> tSdtAwardList = userInfoDao.getTSdtAwardByMids(prentIds);

				for (TSdtTutorPrentInfo tutorPrentInfo : tSdtTutorPrentInfos) {
					List<TSdtPrentInfo> tSdtPrentInfos = new ArrayList<>();
					for (TSdtPrentInfo tSdtPrentInfo : tSdtPrentInfoList) {

						if (!tSdtAwardList.isEmpty()) {
							List<TSdtAward> tSdtAwards = new ArrayList<>();
							for (TSdtAward tSdtAward : tSdtAwardList) {
								if (tSdtAward.getSdtTdId().equals(tSdtPrentInfo.getId())) {
									tSdtAwards.add(tSdtAward);
								}
							}

							tSdtPrentInfo.settSdtAwardList(tSdtAwards);
						}

						if (tutorPrentInfo.getId().equals(tSdtPrentInfo.getSdtId())) {
							tSdtPrentInfos.add(tSdtPrentInfo);
						}
					}

					tutorPrentInfo.settSdtPrentInfo(tSdtPrentInfos);
				}
			}
		}

	}

	/**
	 * 项目课题成果
	 *
	 * @param tProjAchieveInfo
	 * @param user
	 */
	@Override
	@Transactional
	public String addProjAchieveInfo(TProjAchieveInfo tProjAchieveInfo, User user) throws Exception {
		if (!("0").equals(tProjAchieveInfo.getIsAdd())){
			List<TSalaryBusinessBind> list = userInfoDao.selectSalaryBusinessBind(t_proj_achieve_info,tProjAchieveInfo.getOrignalId());
			if(!CollectionUtils.isEmpty(list)){
				return "当前数据已用于薪档申报，不可修改！";
			}
		}

		tProjAchieveInfo.setUpdaterId(user.getFax());
		tProjAchieveInfo.setUpdaterName(user.getName());
		List<TPartRank> rankList = tProjAchieveInfo.gettPartRankList();
		// 根据erp_no过滤重复选中的人
		List<TPartRank> ranks = rankList.stream()
				.collect(Collectors.collectingAndThen(
						Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(TPartRank::getErpNo))),
						ArrayList::new));
		if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
			// 管理员给自己新增的时候要判断参与人里面有没有自己，如果给别人添加的时候要判断有没有选中当前选择的人，如果没有就不允许添加
			boolean flag = judgeTPartRankIsContainCurrentUser(ranks, tProjAchieveInfo.getErpNo());
			if (!flag) {
				// 返回错误信息
				String message = "";
				if (tProjAchieveInfo.getErpNo().equals(user.getFax())) {// 给自己添加
					message = "当前添加的参与人员中没有包含当前登录人";
				} else {// 给别人添加
					message = "当前添加的参与人员中没有包含当前选中的人";
				}
				return message;
			}
		} else {// 普通用户
				// 普通人员新增的时候要判断参与人里面有没有当前登录人，如果没有就不允许添加
			boolean flag = judgeTPartRankIsContainCurrentUser(ranks, user.getFax());
			if (!flag) {
				// 返回错误信息
				String message = "当前添加的参与人员中没有包含当前登录人自己";
				return message;
			}
		}
		// isAdd=0，表示新增，isAdd=1表示正常编辑，isAdd=2表示审核时编辑(但是审核时编辑未走当前方法，走的是WorkFlowController里面的接口方法);
		// isAdd=3表示在新增时输入课题名称，点击下拉框中匹配的一条数据进行回显，并进行编辑,
		// 此时如果该条数据是待审核的(即flow_status=0)，那么无论是管理员操作还是普通用户操作，状态不变，仍为待审核，
		// 如果该条数据是被驳回的，即(flow_status=3)，那么无论是管理员操作还是普通用户操作，做add操作，新增一条待审核数据，
		// 如果该条数据是有效数据，即(flow_status=1,且is_valid=0)，那么对该条数据进行编辑时走正常流程，即管理员操作后仍是有效数据，普通用户操作新增一条待审核数据
		if (("3").equals(tProjAchieveInfo.getIsAdd())) {
			if (1 == tProjAchieveInfo.getFlowStatus() && 0 == tProjAchieveInfo.getIsValid()) {// 有效的数据
				tProjAchieveInfo.setIsAdd("1");// 走正常编辑流程
			} else {
				String recordId = "";
				if (3 == tProjAchieveInfo.getFlowStatus()) {// 被驳回的
					// 将该条数据状态由被驳回变更为待审核
					tProjAchieveInfo.setFlowStatus(0);// 待审核
					tProjAchieveInfo.setIsValid(1);
					userInfoDao.addProjAchieveInfo(tProjAchieveInfo);
					addPartRank(ranks, tProjAchieveInfo.getId(), "17");
					// 插入工作流
					workFlowAntService.addWorkFlow(user, t_proj_achieve_info, tProjAchieveInfo.getId(), null, null);
					recordId = tProjAchieveInfo.getProgressCheckId();
				} else {
					// 待审核状态的数据状态不变，只能修改参与人
					updatePartRankData(tProjAchieveInfo.getId(), ranks, "17");
					recordId = tProjAchieveInfo.getId();
				}
				// 插入日志
				TProjAchieveInfo oldTProjAchieveInfo = getProjAchieveInfoByIdForRecord(recordId);
				List<TPartRank> tPartRanks = tProjAchieveInfo.gettPartRankList();
				if (tPartRanks.size() > 0) {
					for (TPartRank rank : tPartRanks) {
						rank.setRoleName(SysDictionaryUtil.getNameByValueForDefault("XiangMuKeTiJS", rank.getRole()));
					}
				}
				addRecordLogInfo(tProjAchieveInfo, oldTProjAchieveInfo, user, tProjAchieveInfo.getPrimitiveId(),
						tProjAchieveInfo.getId(), "2");
			}
		}
		if (("0").equals(tProjAchieveInfo.getIsAdd())) {// 新增
			// 判断课题名称是否重复--查询对象：有效的、待审核的、被驳回的,不通过的除外
			List<TProjAchieveInfoVo> list = userInfoDao.getProjAchieveInfoByProjName(tProjAchieveInfo.getProjName(),
					user.getBaseOrgId());
			if (list != null && list.size() > 0) {
				return "该课题名称已存在，请在填写名称时选择下拉项进行编辑";
			}
			tProjAchieveInfo.setCreaterId(user.getFax());
			tProjAchieveInfo.setCreaterName(user.getName());
			tProjAchieveInfo.setOrgId(user.getBaseOrgId());// 单位ID
			tProjAchieveInfo.setOrignalId(tProjAchieveInfo.getId());
			tProjAchieveInfo.setPrimitiveId(tProjAchieveInfo.getId());
			tProjAchieveInfo.setBusinessTypeId(t_proj_achieve_info);
			tProjAchieveInfo.setDelSign(0);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				tProjAchieveInfo.setIsValid(0);// 有效
				tProjAchieveInfo.setFlowStatus(1);// 不要审批，默认通过
			} else {
				tProjAchieveInfo.setIsValid(1);// 无效
				tProjAchieveInfo.setFlowStatus(0);// 要审批
				// 添加流程-add by yangwang 20200803
				/*
				 * //先删除之前的审批流程
				 * updateWorkFlowDataByPrimitiveId(tProjAchieveInfo.getPrimitiveId());
				 * addWorkFlowData(tProjAchieveInfo.getId(),tProjAchieveInfo.getPrimitiveId(),
				 * tProjAchieveInfo.getAuditErpNo(),t_proj_achieve_info,user.getFax(),
				 * dealRoleCode);
				 */
//				workFlowAntService.addWorkFlow(user, t_proj_achieve_info, tProjAchieveInfo.getId(), null, null);
			}
			userInfoDao.addProjAchieveInfo(tProjAchieveInfo);
			addPartRank(ranks, tProjAchieveInfo.getId(), "17");
			// 新增插入操作记录
			addRecordLogData(tProjAchieveInfo.getId(), user, "0");
			// 删除草稿箱数据
			draftsService.deleteMes(tProjAchieveInfo.getId(), "t_proj_achieve_info_drafts");
			// 删除草稿箱列表数据
			draftsService.deleteDraftsListByBusinessId(tProjAchieveInfo.getId());
			// 插入工作流
			if (!(("2").equals(user.getRemark()) || ("3").equals(user.getRemark()))) {// 非管理员
				workFlowAntService.addWorkFlow(user, t_proj_achieve_info, tProjAchieveInfo.getId(), null, null);
			}
		} else if (("1").equals(tProjAchieveInfo.getIsAdd()) || ("2").equals(tProjAchieveInfo.getIsAdd())) {// 修改
			//待审核可编辑-xyy
			/*if ("1".equals(tProjAchieveInfo.getIsAdd())) {
				List<TProjAchieveInfo> tProjAchieveInfos = getReadyProjAchieveInfoById(tProjAchieveInfo.getId());
				if (tProjAchieveInfos != null && tProjAchieveInfos.size() > 0) {
					return "当前数据已经存在待审核状态";
				}
			}*/
			// 防止数据直接从数据库维护进去，business_type_id为空，再次编辑的时候还是为空
			tProjAchieveInfo.setBusinessTypeId(t_proj_achieve_info);
			// 日志记录--获取原始业务数据
			String orignalId = "";
			if (!(StringUtil.isNullOrEmpty(tProjAchieveInfo.getProgressCheckId()))) {// 如果是进度查看里的编辑
				orignalId = tProjAchieveInfo.getProgressCheckId();
			} else {
				orignalId = tProjAchieveInfo.getOrignalId();
			}
			TProjAchieveInfo oldTProjAchieveInfo = getProjAchieveInfoByIdForRecord(orignalId);
			//待审核编辑不新增流程-xyy
			List<TProjAchieveInfo> tProjAchieveInfos = getReadyProjAchieveInfoById(tProjAchieveInfo.getOrignalId());
			if ("1".equals(tProjAchieveInfo.getIsAdd()) && tProjAchieveInfos != null && tProjAchieveInfos.size() > 0) {
				tProjAchieveInfo.setId(tProjAchieveInfo.getOrignalId());
				workFlowProcessService.updateTProjAchieveInfo(tProjAchieveInfo, user);
				// 参与人员修改
				updatePartRankData(tProjAchieveInfo.getId(), ranks, "17");
			}else {
				if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
					tProjAchieveInfo.setFlowStatus(1);
					workFlowProcessService.updateTProjAchieveInfo(tProjAchieveInfo, user);
					// 参与人员修改
					updatePartRankData(tProjAchieveInfo.getId(), ranks, "17");
				} else {// 普通用户
					tProjAchieveInfo.setIsValid(1);// 无效
					tProjAchieveInfo.setCreaterId(user.getFax());
					tProjAchieveInfo.setCreaterName(user.getName());
					tProjAchieveInfo.setOrgId(user.getBaseOrgId());
					tProjAchieveInfo.setFlowStatus(0);// 要审批
//				tProjAchieveInfo.setOrignalId(tProjAchieveInfo.getId());
//				tProjAchieveInfo.setId(IdGen.uuid());
					// 参与人员修改
					addPartRank(ranks, tProjAchieveInfo.getId(), "17");
					userInfoDao.addProjAchieveInfo(tProjAchieveInfo);

					// 添加流程-add by yangwang 20200803
					/*
					 * //先删除之前的审批流程
					 * updateWorkFlowDataByPrimitiveId(tProjAchieveInfo.getPrimitiveId());
					 * addWorkFlowData(tProjAchieveInfo.getId(),tProjAchieveInfo.getPrimitiveId(),
					 * tProjAchieveInfo.getAuditErpNo(),t_proj_achieve_info,user.getFax(),
					 * dealRoleCode);
					 */
					workFlowAntService.addWorkFlow(user, t_proj_achieve_info, tProjAchieveInfo.getId(), null, null);
				}
			}

			// 修改插入操作记录
//			addRecordLogData(tProjAchieveInfo.getPrimitiveId(),user,"2");
			oldTProjAchieveInfo.setProjLevel(
					SysDictionaryUtil.getNameByValueForDefault("StandardLevel", oldTProjAchieveInfo.getProjLevel()));
			tProjAchieveInfo.setProjLevel(
					SysDictionaryUtil.getNameByValueForDefault("StandardLevel", tProjAchieveInfo.getProjLevel()));
			List<TPartRank> tPartRanks = tProjAchieveInfo.gettPartRankList();
			if (tPartRanks.size() > 0) {
				for (TPartRank rank : tPartRanks) {
					rank.setRoleName(SysDictionaryUtil.getNameByValueForDefault("XiangMuKeTiJS", rank.getRole()));
				}
			}
			addRecordLogInfo(tProjAchieveInfo, oldTProjAchieveInfo, user, tProjAchieveInfo.getPrimitiveId(),
					tProjAchieveInfo.getId(), "2");
		}
		return null;
	}

	@Override
	public TProjAchieveInfo getProjAchieveInfoByIdForRecord(String id) {
		TProjAchieveInfo tProjAchieveInfo = userInfoDao.getProjAchieveInfoByIdForRecord(id);
		if (tProjAchieveInfo != null) {
			List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(new HashSet<String>() {
				{
					add(tProjAchieveInfo.getId());
				}
			}, "17");
			tProjAchieveInfo.settPartRankList(tPartRankList);
		}
		return tProjAchieveInfo;
	}

	@Override
	public TProjAchieveInfoVo getProjAchieveInfoById(String id) {
		TProjAchieveInfoVo tProjAchieveInfoVo = userInfoDao.getProjAchieveInfoById(id);
		if (tProjAchieveInfoVo != null) {
			List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(new HashSet<String>() {
				{
					add(tProjAchieveInfoVo.getId());
				}
			}, "17");
			tProjAchieveInfoVo.settPartRankList(tPartRankList);
		}
		return tProjAchieveInfoVo;
	}

	@Override
	public List<TProjAchieveInfoVo> getProjAchieveInfoByErpNo(String erpNo) {
		List<TProjAchieveInfoVo> tProjAchieveInfoVos = userInfoDao.getProjAchieveInfoByErpNo(erpNo);
		if (tProjAchieveInfoVos.isEmpty()) {
			return tProjAchieveInfoVos;
		}
		Set<String> ids = new HashSet<>();
		tProjAchieveInfoVos.forEach(i -> ids.add(i.getId()));
		List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(ids, "17");
		if (!tPartRankList.isEmpty()) {
			for (TProjAchieveInfoVo tProjAchieveInfoVo : tProjAchieveInfoVos) {
				List<TPartRank> tPartRankListVo = new ArrayList<>();
				for (TPartRank tPartRank : tPartRankList) {
					if (tProjAchieveInfoVo.getId().equals(tPartRank.getItemId())) {
						tPartRankListVo.add(tPartRank);
					}
				}

				tProjAchieveInfoVo.settPartRankList(tPartRankListVo);
			}
		}

		return tProjAchieveInfoVos;

	}

	@Override
	public void findPageProjAchieveInfoByCondi(Page<TProjAchieveInfoVo> page, TProjAchieveInfo tProjAchieveInfo) {
		userInfoDao.findPageProjAchieveInfoByCondi(page, tProjAchieveInfo);
		if (!page.getResult().isEmpty()) {
			List<TProjAchieveInfoVo> tProjAchieveInfoVos = page.getResult();

			if (tProjAchieveInfoVos.isEmpty()) {
				return;
			}
			Set<String> ids = new HashSet<>();
			tProjAchieveInfoVos.forEach(i -> ids.add(i.getId()));
			List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(ids, "17");
			if (!tPartRankList.isEmpty()) {
				for (TProjAchieveInfoVo tProjAchieveInfoVo : tProjAchieveInfoVos) {
					List<TPartRank> tPartRankListVo = new ArrayList<>();
					for (TPartRank tPartRank : tPartRankList) {
						if (tProjAchieveInfoVo.getId().equals(tPartRank.getItemId())) {
							tPartRankListVo.add(tPartRank);
						}
					}

					tProjAchieveInfoVo.settPartRankList(tPartRankListVo);
				}
			}
		}
	}

	@Override
	public List<TMouldInfo> getMouldInfoList(TMouldInfo tMouldInfo) {
		return userInfoDao.getMouldInfoList(tMouldInfo);
	}

	@Override
	public void getEachTypeDetailList(EachTypeDetailVo detail, Page<EachTypeDetailVo> page) {
		userInfoDao.getEachTypeDetailList(detail, page);
	}

	@Override
	public List<SysDictionaryInfoVo> getAttendanceUserTypeByValue(String value) {
		return userInfoDao.getAttendanceUserTypeByValue(value);
	}

	/****************************************
	 * 1.通过数据id判断当前数据是否存在待审核的副本数据
	 * 2.通过数据id判断当前数据是否已经提报薪档
	 ********************************/

	@Override
	public List<TYearEffectInfo> getReadyYearEffectById(String id) {
		return userInfoDao.getReadyYearEffectById(id);
	}

	@Override
	public List<TSalaryBusinessBind> getYearEffectSalaryById(String id) {
		return userInfoDao.selectSalaryBusinessBind(t_year_effect_info,id);
	}

	@Override
	public List<TEducateInfo> getReadyEducateInfoById(String id) {
		return userInfoDao.getReadyEducateInfoById(id);
	}

	@Override
	public List<TSalaryBusinessBind> getEducateInfoSalaryById(String id) {
		return userInfoDao.selectSalaryBusinessBind(t_educate_info,id);
	}

	@Override
	public List<TProTecInfo> getReadyProTecInfoById(String id) {
		return userInfoDao.getReadyProTecInfoById(id);
	}

	@Override
	public List<TSalaryBusinessBind> getProTecInfoSalaryById(String id) {
		return userInfoDao.selectSalaryBusinessBind(t_pro_tec_info,id);
	}

	@Override
	public List<TSkillLevelInfo> getReadySkillLevelInfoById(String id) {
		return userInfoDao.getReadySkillLevelInfoById(id);
	}

	@Override
	public List<TSalaryBusinessBind> getSkillLevelSalaryById(String id) {
		return userInfoDao.selectSalaryBusinessBind(t_skill_level_info,id);
	}

	@Override
	public List<TExpertTitleInfo> getReadyExpertTitleInfoById(String id) {
		return userInfoDao.getReadyExpertTitleInfoById(id);
	}

	@Override
	public List<TSalaryBusinessBind> getExpertTitleSalaryById(String id) {
		return userInfoDao.selectSalaryBusinessBind(t_expert_title_info,id);
	}

	@Override
	public List<TAcadeAchiveInfo> getReadyAcadeAchiveInfoById(String id) {
		return userInfoDao.getReadyAcadeAchiveInfoById(id);
	}

	@Override
	public List<TSalaryBusinessBind> getAcadeAchiveSalaryById(String id) {
		return userInfoDao.selectSalaryBusinessBind(t_acade_achive_info,id);
	}

	@Override
	public List<TStandInfo> getReadyStandInfoById(String id) {
		return userInfoDao.getReadyStandInfoById(id);
	}

	@Override
	public List<TSalaryBusinessBind> getStandInfoSalaryById(String id) {
		return userInfoDao.selectSalaryBusinessBind(t_stand_info,id);
	}

	@Override
	public List<TPatentInfo> getReadyPatentInfoById(String id) {
		return userInfoDao.getReadyPatentInfoById(id);
	}

	@Override
	public List<TSalaryBusinessBind> getPatentInfoSalaryById(String id) {
		return userInfoDao.selectSalaryBusinessBind(t_patent_info,id);
	}

	@Override
	public List<TTecInnovInfo> getReadyTecInnovInfoById(String id) {
		return userInfoDao.getReadyTecInnovInfoById(id);
	}

	@Override
	public List<TSalaryBusinessBind> getTecInnovInfoSalaryById(String id) {
		return userInfoDao.selectSalaryBusinessBind(t_tec_innov_info,id);
	}

	@Override
	public List<TContestInfo> getReadyContestInfoById(String id) {
		return userInfoDao.getReadyContestInfoById(id);
	}

	@Override
	public List<TSalaryBusinessBind> getContestInfoSalaryById(String id) {
		return userInfoDao.selectSalaryBusinessBind(t_contest_info,id);
	}

	@Override
	public List<TTecManInnov> getReadyTecManInnovById(String id) {
		return userInfoDao.getReadyTecManInnovById(id);
	}

	@Override
	public List<TSalaryBusinessBind> getTecManInnovSalaryById(String id) {
		return userInfoDao.selectSalaryBusinessBind(t_tec_man_innov,id);
	}

	@Override
	public List<THonorInfo> getReadyHonorInfoById(String id) {
		return userInfoDao.getReadyHonorInfoById(id);
	}

	@Override
	public List<TSalaryBusinessBind> getHonorInfoSalaryById(String id) {
		return userInfoDao.selectSalaryBusinessBind(t_honor_info,id);
	}

	@Override
	public List<TWorkExpInfo> getReadyWorkExpInfoById(String id) {
		return userInfoDao.getReadyWorkExpInfoById(id);
	}

	@Override
	public List<TSalaryBusinessBind> getWorkExpInfoSalaryById(String id) {
		return userInfoDao.selectSalaryBusinessBind(t_work_exp_info,id);
	}

	@Override
	public List<TContiStudyInfo> getReadyContiStudyInfoById(String id) {
		return userInfoDao.getReadyContiStudyInfoById(id);
	}

	@Override
	public List<TSalaryBusinessBind> getContiStudyInfoSalaryById(String id) {
		return userInfoDao.selectSalaryBusinessBind(t_conti_study_info,id);
	}

	@Override
	public List<TSdtTutorPrentInfo> getReadySdtTutorPrentInfoById(String id) {
		return userInfoDao.getReadySdtTutorPrentInfoById(id);
	}

	@Override
	public List<TSalaryBusinessBind> getSdtTutorPrentInfoSalaryById(String id) {
		return userInfoDao.selectSalaryBusinessBind(t_sdt_tutor_prent_info,id);
	}

	@Override
	public List<TProjAchieveInfo> getReadyProjAchieveInfoById(String id) {
		return userInfoDao.getReadyProjAchieveInfoById(id);
	}

	@Override
	public List<TSalaryBusinessBind> getProjAchieveInfoSalaryById(String id) {
		return userInfoDao.selectSalaryBusinessBind(t_proj_achieve_info,id);
	}

	/**
	 * 参与人员新增
	 *
	 * @param ranks
	 * @param id
	 * @param type
	 */
	public void addPartRank(List<TPartRank> ranks, String id, String type) {
		if (ranks.size() > 0) {
			ranks.forEach(p -> {
				p.setId(IdGen.uuid());
				p.setItemId(id);
				p.setItemType(type);
				p.setIsValid(1);// 无效
				if (StringUtil.isNullOrEmpty(p.getErpNo())) {
					p.setErpNo(p.getUserName());
				}
				userInfoDao.addPartRank(p);
			});
		}
	}

	/**
	 * 参与人员修改
	 */
	public void updatePartRankData(String itemId, List<TPartRank> list, String itemType) {
		// 先删除
		humanDataDao.deleteTPartRankByCondition(null, itemId);
		// 再插入
		if (list.size() > 0) {
			list.forEach(p -> {
				p.setItemId(itemId);
				p.setId(IdGen.uuid());
				p.setItemType(itemType);
				p.setIsValid(0);// 有效
				if (StringUtil.isNullOrEmpty(p.getErpNo())) {
					p.setErpNo(p.getUserName());
				}
				userInfoDao.addPartRank(p);
			});
		}
	}

	/**
	 * 插入审批流程表
	 */
	public void addWorkFlowData(String businessId, String primitiveId, String auditErpNo, String businessTypeId,
			String fax, String dealRoleCode) {
		TWorkFlow work = new TWorkFlow();
		work.setId(IdGen.uuid());
		work.setBusinessId(businessId);
		work.setDealErpNo(auditErpNo);
		work.setBusinessTypeId(businessTypeId);// 当前业务数据ID
		work.setPrimitiveId(primitiveId);// 原始数据ID，用于和最初的那条数据进行关联
		work.setCreaterId(fax);
//		work.setIsValid(1);
		work.setDelSign(0);
		work.setStatus("0");
		work.setDealRoleCode(dealRoleCode);
		workFlowDao.saveWorkFlowInfo(work);
	}

	/**
	 * 公共方法--插入操作记录
	 */
	public void addRecordLogData(String recordId, User user, String optType) {
		// 插入操作记录
		TRecordOptLog log = new TRecordOptLog();
		log.setRecordId(recordId);
		log.setCurrentRecordId(recordId);
		log.setOptStatus(0);// 日志记录中记录为待审核
		if (optType.equals("0")) {// 新增
			log.setOptContent(user.getName() + "新增了数据");
		} else if (optType.equals("2")) {// 编辑
			log.setOptContent(user.getName() + "编辑了数据");
		}
		log.setOptType(optType);
		recordLogService.save(user, log);
	}

	/**
	 * 公共方法--新的操作记录方法
	 */
	public void addRecordLogInfo(Object newObject, Object oldObject, User user, String recoreId, String currentRecordId,
			String type) {
		TRecordOptLog record = new TRecordOptLog();
		record.setRecordId(recoreId);
		record.setCurrentRecordId(currentRecordId);
		record.setOptType(type);
		if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
			record.setOptStatus(1);// 日志记录中记录为通过
		} else {
			record.setOptStatus(0);// 日志记录中记录为待审核
		}
		recordLogService.save(newObject, oldObject, record, user, "0", "0");// 前面一个参数代表修改/审核，0代表修改，1代表审核；后面一个参数代表是移动端操作/pc端操作，0代表pc端，1代表移动端
	}

	@Override
	public void addSdtPrentInfo(TSdtPrentInfo p) {
		userInfoDao.addSdtPrentInfo(p);
	}

	public boolean judgeTPartRankIsContainCurrentUser(List<TPartRank> ranks, String fax) {
		// 普通人员新增的时候要判断参与人里面有没有当前登录人，如果没有就不允许添加
		boolean flag = false;
		for (TPartRank rank : ranks) {
			if (rank.getErpNo().equals(fax)) {
				flag = true;
			}
		}
		return flag;
	}

	/**
	 * 公共方法--根据原始数据ID删除审批流程表work_flow中之前的审批记录，以防止一条数据在进度查看中展示多次审批记录
	 */
	public void updateWorkFlowDataByPrimitiveId(String primitiveId) {
		workFlowDao.updateWorkFlowDataByPrimitiveId(primitiveId);
	}

	/**
	 * 公共方法获取审核的角色
	 */
	public String getDealRoleId(String businessTypeId, String orgId) throws Exception {
		TBusinessWorkflowBind tBusinessWorkflowBind = new TBusinessWorkflowBind();
		tBusinessWorkflowBind.setBusinessTypeId(businessTypeId);
		tBusinessWorkflowBind.setOrgId(orgId);
		List<TBusinessWorkflowBind> list = tBusinessWorkflowBindDao
				.getDealRoleIdByOrgIdAndBusinessTypeId(tBusinessWorkflowBind);
		String dealRoleId = null;
		if (list != null && list.size() > 0) {
			dealRoleId = list.get(0).getDealRoleId();
		}
		return dealRoleId;
	}

	/**
	 * 添加挂职轮岗信息
	 *
	 * @author yangwang
	 * @param tRotationInfo
	 * @param user
	 * @return String
	 */
	@Override
	@Transactional
	public String addRotationInfo(TRotationInfo tRotationInfo, User user) throws Exception {
		tRotationInfo.setUpdaterId(user.getFax());
		tRotationInfo.setUpdaterName(user.getName());
		if (tRotationInfo.getIsAdd().equals("0")) {// 新增
			tRotationInfo.setCreaterId(user.getFax());
			tRotationInfo.setCreaterName(user.getName());
			tRotationInfo.setOrgId(user.getBaseOrgId());// 单位ID
			tRotationInfo.setOrignalId(tRotationInfo.getId());
			tRotationInfo.setPrimitiveId(tRotationInfo.getId());
			tRotationInfo.setBusinessTypeId(t_rotation_info);
			tRotationInfo.setDelSign(0);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				tRotationInfo.setIsValid(0);
				tRotationInfo.setFlowStatus(1);// 不要审批，默认通过
			} else {
				tRotationInfo.setIsValid(1);
				tRotationInfo.setFlowStatus(0);// 要审批

				// 添加流程-add by yangwang 20200803
				/*
				 * //先删除之前的审批流程
				 * //updateWorkFlowDataByPrimitiveId(tRotationInfo.getPrimitiveId());
				 * addWorkFlowData(tRotationInfo.getId(),tRotationInfo.getPrimitiveId(),
				 * tRotationInfo.getAuditErpNo(),t_rotation_info,user.getFax(),dealRoleCode);
				 */
//				workFlowAntService.addWorkFlow(user, t_rotation_info, tRotationInfo.getId(), null, null);
			}
			userInfoDao.addRotationInfo(tRotationInfo);
			// 新增插入操作记录
			addRecordLogData(tRotationInfo.getId(), user, "0");
			// 删除草稿箱数据
			draftsService.deleteMes(tRotationInfo.getId(), "t_rotation_info_drafts");
			// 删除草稿箱列表数据
			draftsService.deleteDraftsListByBusinessId(tRotationInfo.getId());
			// 插入工作流
			if (!(("2").equals(user.getRemark()) || ("3").equals(user.getRemark()))) {// 非管理员
				workFlowAntService.addWorkFlow(user, t_rotation_info, tRotationInfo.getId(), null, null);
			}
		} else {// 修改
			List<TSalaryBusinessBind> list = userInfoDao.selectSalaryBusinessBind(t_rotation_info,tRotationInfo.getOrignalId());
			if(!CollectionUtils.isEmpty(list)){
				return "当前数据已用于薪档申报，不可修改！";
			}
			if ("1".equals(tRotationInfo.getIsAdd())) {
				List<TRotationInfo> tRotationInfos = getReadyRotationInfoById(tRotationInfo.getId());
				if (tRotationInfos != null && tRotationInfos.size() > 0) {
					return "当前数据已经存在待审核状态";
				}
			}
			tRotationInfo.setBusinessTypeId(t_rotation_info);
			// 日志记录--获取原始业务数据
			String orignalId = "";
			if (!(StringUtil.isNullOrEmpty(tRotationInfo.getProgressCheckId()))) {// 如果是进度查看里的编辑
				orignalId = tRotationInfo.getProgressCheckId();
			} else {
				orignalId = tRotationInfo.getOrignalId();
			}
			TRotationInfo oldTRotationInfo = userInfoDao.getRotationInfoById(orignalId);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				tRotationInfo.setFlowStatus(1);
				workFlowProcessService.updateTRotationInfo(tRotationInfo, user);
			} else {// 普通用户
				tRotationInfo.setIsValid(1);
				tRotationInfo.setFlowStatus(0);// 要审批
				tRotationInfo.setCreaterId(user.getFax());
				tRotationInfo.setCreaterName(user.getName());
				tRotationInfo.setOrgId(user.getBaseOrgId());
//				tRotationInfo.setOrignalId(tRotationInfo.getId());
//				tRotationInfo.setId(IdGen.uuid());
				userInfoDao.addRotationInfo(tRotationInfo);

				// 添加流程-add by yangwang 20200803
				/*
				 * //先删除之前的审批流程 updateWorkFlowDataByPrimitiveId(tRotationInfo.getPrimitiveId());
				 * addWorkFlowData(tRotationInfo.getId(),tRotationInfo.getPrimitiveId(),
				 * tRotationInfo.getAuditErpNo(),t_rotation_info,user.getFax(),dealRoleCode);
				 */
				workFlowAntService.addWorkFlow(user, t_rotation_info, tRotationInfo.getId(), null, null);
			}
			// 修改插入操作记录
//			addRecordLogData(tRotationInfo.getPrimitiveId(),user,"2");
			// 日志记录
			addRecordLogInfo(tRotationInfo, oldTRotationInfo, user, tRotationInfo.getPrimitiveId(),
					tRotationInfo.getId(), "2");
		}
		return null;
	}

	/**
	 * 根据id获取挂职轮岗信息
	 *
	 * @author yangwang
	 * @param id
	 * @return TRotationInfo
	 */
	@Override
	public TRotationInfo getRotationInfoById(String id) {
		return userInfoDao.getRotationInfoById(id);
	}

	/**
	 * 获取挂职轮岗列表信息
	 *
	 * @author yangwang
	 * @param tRotationInfo
	 * @return List<TRotationInfo>
	 */
	@Override
	public List<TRotationInfo> getListRotationInfoCondi(TRotationInfo tRotationInfo) {
		return userInfoDao.getListRotationInfoByCondi(tRotationInfo);
	}

	/**
	 * 获取挂职轮岗分页信息
	 *
	 * @author yangwang
	 * @param page
	 * @param tRotationInfo
	 */
	@Override
	public void findPageRotationInfoByCondi(Page<TRotationInfo> page, TRotationInfo tRotationInfo) {
		userInfoDao.findPageRotationInfoByCondi(page, tRotationInfo);
	}

	/**
	 * 获取挂职轮岗待审核信息
	 *
	 * @author yangwang
	 * @param id
	 * @return List<TRotationInfo>
	 */
	@Override
	public List<TRotationInfo> getReadyRotationInfoById(String id) {
		return userInfoDao.getReadyRotationInfoById(id);
	}

	@Override
	public List<TSalaryBusinessBind> getRotationInfoSalaryById(String id) {
		return userInfoDao.selectSalaryBusinessBind(t_rotation_info,id);
	}

	@Override
	public List<TSdtPrentInfo> getTSdtPrentInfoListById(String id) {
		return userInfoDao.getTSdtPrentInfoListById(id);
	}

	@Override
	public void addSdtAwardInfo(TSdtAward tSdtAward) {
		userInfoDao.addSdtAwardInfo(tSdtAward);
	}

	@Override
	public TEmpBaseInfoVo getNowBaseInfoByErpNo(String erpNo) {
		TEmpBaseInfoVo entity = userInfoDao.getNowBaseInfoByErpNo(erpNo);
		if (entity != null) {
			if (entity.getAcquTime() != null) {
				Calendar calendar = Calendar.getInstance();
				calendar.setTime(entity.getAcquTime());
				calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) + 5); // 增加5年
				Date date = calendar.getTime();
				Date now = new Date();
				if (date.before(now)) {
					entity.setEmpTitleName(null);
				}
			}
		}
		return entity;
	}

	@Override
	public FuturePostVo getFuturePostByErpNo(String erpNo) {
		return userInfoDao.getFuturePostByErpNo(erpNo);
	}

	@Override
	public void addGrowthPlan(TGrowthPlan tGrowthPlan, User user) {
		// 新增编辑操作记录
		String recordId = tGrowthPlan.getId();
		// 插入操作记录
		TRecordOptLog log = new TRecordOptLog();
		log.setRecordId(recordId);
		log.setCurrentRecordId(recordId);
//		log.setOptStatus(1);// 日志记录中记录为待审核
		log.setOptContent(user.getName() + "新增了数据");
		log.setOptType("1");
		recordLogService.save(user, log);
		// 删除草稿箱数据
		draftsService.deleteMes(tGrowthPlan.getId(), "t_growth_plan_drafts");
		// 删除草稿箱列表数据
		draftsService.deleteDraftsListByBusinessId(tGrowthPlan.getId());
		userInfoDao.addGrowthPlan(tGrowthPlan, user);
	}

	@Override
	public void findPageGrowthPlanByCondi(Page<TGrowthPlan> page, TGrowthPlan tGrowthPlan) {
		userInfoDao.findPageGrowthPlanByCondi(page, tGrowthPlan);
	}

	@Override
	public TGrowthPlan getGrowthPlanById(String id) {
		return userInfoDao.getGrowthPlanById(id);
	}

	@Override
	public void updateGrowthPlan(TGrowthPlan tGrowthPlan, User user) {
		// 新增编辑操作记录
		String recordId = tGrowthPlan.getId();
		// 插入操作记录
		TRecordOptLog log = new TRecordOptLog();
		log.setRecordId(recordId);
		log.setCurrentRecordId(recordId);
//		log.setOptStatus(1);// 日志记录中记录为待审核
		log.setOptContent(user.getName() + "编辑了数据");
		log.setOptType("1");
		recordLogService.save(user, log);
		userInfoDao.updateGrowthPlan(tGrowthPlan, user);
	}

	@Override
	public List<TGrowthPlan> getListByCondition(TGrowthPlan tGrowthPlan, String ids) {
		return userInfoDao.getListByCondition(tGrowthPlan, ids);
	}

	@Override
	public void getPersonalPageGrowthPlanByErpNo(Page<TGrowthPlan> page, String erpNo) {
		userInfoDao.getPersonalPageGrowthPlanByErpNo(page, erpNo);
	}

	@Override
	public DeptIdPathVo getDeptIdPathById(String deptId) {
		return userInfoDao.getDeptIdPathById(deptId);
	}

	@Override
	public String addEmployeeMobility(TEmployeeMobility tEmployeeMobility, User user) {
		tEmployeeMobility.setUpdaterId(user.getFax());
		tEmployeeMobility.setUpdaterName(user.getName());
		if (tEmployeeMobility.getIsAdd().equals("0")) {// 新增
			tEmployeeMobility.setCreaterId(user.getFax());
			tEmployeeMobility.setCreaterName(user.getName());
			tEmployeeMobility.setOrgId(user.getBaseOrgId());// 单位ID
			tEmployeeMobility.setOrignalId(tEmployeeMobility.getId());
			tEmployeeMobility.setPrimitiveId(tEmployeeMobility.getId());
			tEmployeeMobility.setBusinessTypeId(t_employee_mobility);
			tEmployeeMobility.setDelSign(0);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				tEmployeeMobility.setIsValid(0);
				tEmployeeMobility.setFlowStatus(1);// 不要审批，默认通过
			} else {
				tEmployeeMobility.setIsValid(1);
				tEmployeeMobility.setFlowStatus(0);// 要审批

				// 添加流程-add by yangwang 20200803
				/*
				 * //先删除之前的审批流程
				 * //updateWorkFlowDataByPrimitiveId(tEducateInfo.getPrimitiveId());
				 * addWorkFlowData(tEducateInfo.getId(),tEducateInfo.getPrimitiveId(),
				 * tEducateInfo.getAuditErpNo(),t_educate_info,user.getFax(),dealRoleCode);
				 */
				//workFlowAntService.addWorkFlow(user, t_employee_mobility, tEmployeeMobility.getId(), null, null);
			}
			userInfoDao.addEmployeeMobility(tEmployeeMobility);
			// 新增插入操作记录
			addRecordLogData(tEmployeeMobility.getId(), user, "0");
			// 删除草稿箱数据
			draftsService.deleteMes(tEmployeeMobility.getId(), "t_employee_mobility_drafts");
			// 删除草稿箱列表数据
			draftsService.deleteDraftsListByBusinessId(tEmployeeMobility.getId());
			if (!(("2").equals(user.getRemark()) || ("3").equals(user.getRemark()))) {// 非管理员
				workFlowAntService.addWorkFlow(user, t_employee_mobility, tEmployeeMobility.getId(), null, null);
			}
		} else {// 修改
			List<TSalaryBusinessBind> list = userInfoDao.selectSalaryBusinessBind(t_employee_mobility,tEmployeeMobility.getOrignalId());
			if(!CollectionUtils.isEmpty(list)){
				return "当前数据已用于薪档申报，不可修改！";
			}
			if ("1".equals(tEmployeeMobility.getIsAdd())) {
				List<TEmployeeMobility> tEducateInfos = getReadyEmployeeMobilityById(tEmployeeMobility.getId());
				if (tEducateInfos != null && tEducateInfos.size() > 0) {
					return "当前数据已经存在待审核状态";
				}
			}
			tEmployeeMobility.setBusinessTypeId(t_employee_mobility);// 防止数据直接从数据库维护进去，business_type_id为空，再次编辑的时候还是为空
			// 日志记录--获取原始业务数据
			String orignalId = "";
			if (!(StringUtil.isNullOrEmpty(tEmployeeMobility.getProgressCheckId()))) {// 如果是进度查看里的编辑
				orignalId = tEmployeeMobility.getProgressCheckId();
			} else {
				orignalId = tEmployeeMobility.getOrignalId();
			}
			TEmployeeMobility oldTEmployeeMobility = userInfoDao.getEmployeeMobilityById(orignalId);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				tEmployeeMobility.setFlowStatus(1);
				workFlowService.updateTEmployeeMobility(tEmployeeMobility, user);
			} else {// 普通用户
				tEmployeeMobility.setIsValid(1);
				tEmployeeMobility.setFlowStatus(0);// 要审批
				tEmployeeMobility.setCreaterId(user.getFax());
				tEmployeeMobility.setCreaterName(user.getName());
				tEmployeeMobility.setOrgId(user.getBaseOrgId());
//				tEducateInfo.setOrignalId(tEducateInfo.getId());
//				tEducateInfo.setId(IdGen.uuid());
				userInfoDao.addEmployeeMobility(tEmployeeMobility);

				// 添加流程-add by yangwang 20200803
				/*
				 * //先删除之前的审批流程 updateWorkFlowDataByPrimitiveId(tEducateInfo.getPrimitiveId());
				 * addWorkFlowData(tEducateInfo.getId(),tEducateInfo.getPrimitiveId(),
				 * tEducateInfo.getAuditErpNo(),t_educate_info,user.getFax(),dealRoleCode);
				 */
				workFlowAntService.addWorkFlow(user, t_employee_mobility, tEmployeeMobility.getId(), null, null);
			}
			// 修改插入操作记录
//			addRecordLogData(tEducateInfo.getPrimitiveId(),user,"2");
			// 日志记录
			tEmployeeMobility.setFlowMode(
					SysDictionaryUtil.getNameByValueForDefault("FlowMode", oldTEmployeeMobility.getFlowMode()));
			tEmployeeMobility.setFlowArea(SysDictionaryUtil.getNameByValueForDefault("FlowArea",
					oldTEmployeeMobility.getFlowArea()));
			tEmployeeMobility.setFlowType(
					SysDictionaryUtil.getNameByValueForDefault("FlowType", oldTEmployeeMobility.getFlowType()));
			addRecordLogInfo(tEmployeeMobility, oldTEmployeeMobility, user, tEmployeeMobility.getPrimitiveId(), tEmployeeMobility.getId(),
					"2");
			tEmployeeMobility.setBeginTime(oldTEmployeeMobility.getBeginTime());
			tEmployeeMobility.setEndTime(oldTEmployeeMobility.getEndTime());
		}
		return null;

	}

	@Override
	public void findPageEmployeeMobilityByCondi(Page<TEmployeeMobility> page, TEmployeeMobility tEmployeeMobility) {
		userInfoDao.findPageEmployeeMobilityByCondi(page, tEmployeeMobility);
		if (!page.getResult().isEmpty()) {
			page.getResult().forEach(p -> {
				p.setFlowAreaStr(SysDictionaryUtil.getNameByValueForDefault("FlowArea", p.getFlowArea()));
				p.setFlowTypeStr(SysDictionaryUtil.getNameByValueForDefault("FlowType", p.getFlowType()));
				p.setFlowModeStr(SysDictionaryUtil.getNameByValueForDefault("FlowMode", p.getFlowMode()));
			});
		}
	}

	@Override
	public void getPersonalPageEmployeeMobilityByErpNo(Page<TEmployeeMobility> page, String erpNo) {
		userInfoDao.getPersonalPageEmployeeMobilityByErpNo(page, erpNo);
		if (!page.getResult().isEmpty()) {
			page.getResult().forEach(p -> {
				p.setFlowAreaStr(SysDictionaryUtil.getNameByValueForDefault("FlowArea", p.getFlowArea()));
				p.setFlowTypeStr(SysDictionaryUtil.getNameByValueForDefault("FlowType", p.getFlowType()));
				p.setFlowModeStr(SysDictionaryUtil.getNameByValueForDefault("FlowMode", p.getFlowMode()));
			});
		}
	}

	@Override
	public void updateEmployeeMobility(TEmployeeMobility tEmployeeMobility, User user) {
		userInfoDao.updateEmployeeMobility(tEmployeeMobility, user);
	}

	@Override
	public TEmployeeMobility getEmployeeMobilityById(String id) {
		return userInfoDao.getEmployeeMobilityById(id);
	}

	@Override
	public List<TEmployeeMobility> getReadyEmployeeMobilityById(String id) {
		return userInfoDao.getReadyEmployeeMobilityById(id);
	}

	@Override
	public List<TSalaryBusinessBind> getEmployeeMobilitySalaryById(String id) {
		return userInfoDao.selectSalaryBusinessBind(t_employee_mobility,id);
	}

	/**
	 * 获取技术标准信息
	 * @author pengmengzhi
	 * @param tecStandardInfo
	 * @return List<TRotationInfo>
	 *  */
	@Override
	public void findPageTecStandardInfoByCondi(Page<TTecStandardInfo> page, TTecStandardInfo tecStandardInfo){
		userInfoDao.findPageTecStandardInfoByCondi(page, tecStandardInfo);

		if (!page.getResult().isEmpty()) {
			List<TTecStandardInfo> tecStandardInfoVos = page.getResult();

			if (tecStandardInfoVos.isEmpty()) {
				return;
			}
			Set<String> ids = new HashSet<>();
			tecStandardInfoVos.forEach(i -> ids.add(i.getId()));
			List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(ids, "21");
			if (!tPartRankList.isEmpty()) {
				for (TTecStandardInfo tecStandardInfoVo : tecStandardInfoVos) {
					List<TPartRank> tPartRankListVo = new ArrayList<>();
					for (TPartRank tPartRank : tPartRankList) {
						if (tecStandardInfoVo.getId().equals(tPartRank.getItemId())) {
							tPartRankListVo.add(tPartRank);
						}
					}
					tecStandardInfoVo.setStandardTypeStr(SysDictionaryUtil.getNameByValueForDefault("tecStandardType", tecStandardInfoVo.getStandardType()));
					tecStandardInfoVo.settPartRankList(tPartRankListVo);
				}
			}
		}
	}

	@Override
	public TTecStandardInfo getTecStandardInfoById(String id){
		TTecStandardInfo tTecStandardInfoVo = userInfoDao.getTecStandardInfoById(id);
		if (tTecStandardInfoVo != null) {
			List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(new HashSet<String>() {
				{
					add(id);
				}
			}, "21");
			tTecStandardInfoVo.settPartRankList(tPartRankList);
		}
		return tTecStandardInfoVo;
	}

	@Override
	public String addTecStandardInfo(TTecStandardInfo tecStandardInfo, User user) throws Exception{
		if (!("0").equals(tecStandardInfo.getIsAdd())){
			List<TSalaryBusinessBind> list = userInfoDao.selectSalaryBusinessBind(t_tec_standard_info,tecStandardInfo.getOrignalId());
			if(!CollectionUtils.isEmpty(list)){
				return "当前数据已用于薪档申报，不可修改！";
			}
		}

		tecStandardInfo.setUpdaterId(user.getFax());
		tecStandardInfo.setUpdaterName(user.getName());
		List<TPartRank> rankList = tecStandardInfo.gettPartRankList();
		// 根据erp_no过滤重复选中的人
		List<TPartRank> ranks = rankList.stream()
				.collect(Collectors.collectingAndThen(
						Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(TPartRank::getErpNo))),
						ArrayList::new));
		if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
			// 管理员给自己新增的时候要判断参与人里面有没有自己，如果给别人添加的时候要判断有没有选中当前选择的人，如果没有就不允许添加
			boolean flag = judgeTPartRankIsContainCurrentUser(ranks, tecStandardInfo.getErpNo());
			if (!flag) {
				// 返回错误信息
				String message = "当前添加的参与人员中没有包含当前选中的人";
				return message;
			}
		} else {// 普通用户
			// 普通人员新增的时候要判断参与人里面有没有当前登录人，如果没有就不允许添加
			boolean flag = judgeTPartRankIsContainCurrentUser(ranks, user.getFax());
			if (!flag) {
				// 返回错误信息
				String message = "当前添加的参与人员中没有包含当前登录人自己";
				return message;
			}
		}
		// isAdd=0，表示新增，isAdd=1表示正常编辑，isAdd=2表示审核时编辑(但是审核时编辑未走当前方法，走的是WorkFlowController里面的接口方法);
		// isAdd=3表示在新增时输入论文名称，点击下拉框中匹配的一条数据进行回显，并进行编辑,目前仅支持对参与人进行新增
		// 此时如果该条数据是待审核的(即flow_status=0)，那么无论是管理员操作还是普通用户操作，状态不变，仍为待审核，做update操作，
		// 如果该条数据是被驳回的，即(flow_status=3)，那么无论是管理员操作还是普通用户操作，新增一条待审核数据，做add操作，
		// 如果该条数据是有效数据，即(flow_status=1,且is_valid=0)，那么对该条数据进行编辑时走正常流程，即管理员操作后仍是有效数据，做update操作，普通用户操作新增一条待审核数据，做add操作
		if (("3").equals(tecStandardInfo.getIsAdd())) {
			if (1 == tecStandardInfo.getFlowStatus() && 0 == tecStandardInfo.getIsValid()) {// 有效的数据
				tecStandardInfo.setIsAdd("1");// 走正常编辑流程
			} else {
				String recordId = "";
				if (3 == tecStandardInfo.getFlowStatus()) {// 被驳回的，不管是管理员或是普通人员操作，都做add操作，并插入工作流
					// 插入一条新的待审核数据
					tecStandardInfo.setFlowStatus(0);// 待审核
					tecStandardInfo.setIsValid(1);
					userInfoDao.addTecStandardInfo(tecStandardInfo);
					// 参与人
					addPartRank(ranks, tecStandardInfo.getId(), "21");
					// 插入工作流
					workFlowAntService.addWorkFlow(user, t_tec_standard_info, tecStandardInfo.getId(), null, null);
					recordId = tecStandardInfo.getProgressCheckId();
				} else {
					// 待审核状态的数据状态不变，只能修改参与人
					updatePartRankData(tecStandardInfo.getId(), ranks, "21");
					recordId = tecStandardInfo.getId();
				}
				// 插入日志
				TTecStandardInfo oldTTecStandardInfo = getTecStandardInfoByIdForRecord(recordId);
				List<TPartRank> tPartRanks = tecStandardInfo.gettPartRankList();
				if (tPartRanks.size() > 0) {
					for (TPartRank rank : tPartRanks) {
						rank.setRoleName(
								SysDictionaryUtil.getNameByValueForDefault("tecStandardRole", rank.getRole()));
					}
				}
				addRecordLogInfo(tecStandardInfo, oldTTecStandardInfo, user, tecStandardInfo.getPrimitiveId(),
						tecStandardInfo.getId(), "2");
			}
		}
		if (("0").equals(tecStandardInfo.getIsAdd())) {// 新增
			// 判断技术标准名称是否重复--查询对象：有效的、待审核的、被驳回的,不通过的除外
			List<TTecStandardInfo> list = userInfoDao.getTecStandardInfoByAcadName(tecStandardInfo.getStandardName(),
					user.getBaseOrgId());
			if (list != null && list.size() > 0) {
				return "该技术标准名称已存在，请重新填写填写";
			}
			tecStandardInfo.setCreaterId(user.getFax());
			tecStandardInfo.setCreaterName(user.getName());
			tecStandardInfo.setOrgId(user.getBaseOrgId());// 单位ID
			tecStandardInfo.setOrignalId(tecStandardInfo.getId());
			tecStandardInfo.setPrimitiveId(tecStandardInfo.getId());
			tecStandardInfo.setBusinessTypeId(t_tec_standard_info);
			tecStandardInfo.setDelSign(0);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				tecStandardInfo.setIsValid(0);
				tecStandardInfo.setFlowStatus(1);// 不要审批，默认通过
			} else {
				tecStandardInfo.setIsValid(1);
				tecStandardInfo.setFlowStatus(0);// 要审批
			}
			userInfoDao.addTecStandardInfo(tecStandardInfo);
			addPartRank(ranks, tecStandardInfo.getId(), "21");
			// 新增插入操作记录
			addRecordLogData(tecStandardInfo.getId(), user, "0");
			// 删除草稿箱数据
			draftsService.deleteMes(tecStandardInfo.getId(), "t_tec_standard_info_drafts");
			// 删除草稿箱列表数据
			draftsService.deleteDraftsListByBusinessId(tecStandardInfo.getId());
			// 插入工作流
			if (!(("2").equals(user.getRemark()) || ("3").equals(user.getRemark()))) {// 非管理员
				workFlowAntService.addWorkFlow(user, t_tec_standard_info, tecStandardInfo.getId(), null, null);
			}
		} else if (("1").equals(tecStandardInfo.getIsAdd()) || ("2").equals(tecStandardInfo.getIsAdd())) {
			if ("1".equals(tecStandardInfo.getIsAdd())) {
				List<TTecStandardInfo> tTecStandardInfos = getReadyTecStandardInfoById(tecStandardInfo.getId());
				if (tTecStandardInfos != null && tTecStandardInfos.size() > 0) {
					return "当前数据已经存在待审核状态";
				}
			}
			// 防止数据直接从数据库维护进去，business_type_id为空，再次编辑的时候还是为空
			tecStandardInfo.setBusinessTypeId(t_tec_standard_info);
			// 日志记录--获取原始业务数据
			String orignalId = "";
			if (!(StringUtil.isNullOrEmpty(tecStandardInfo.getProgressCheckId()))) {// 如果是进度查看里的编辑
				orignalId = tecStandardInfo.getProgressCheckId();
			} else {
				orignalId = tecStandardInfo.getOrignalId();
			}
			TTecStandardInfo oldTecStandardInfo = getTecStandardInfoByIdForRecord(orignalId);
			if (("2").equals(user.getRemark()) || ("3").equals(user.getRemark())) {// 管理员
				tecStandardInfo.setFlowStatus(1);
				workFlowProcessService.updateTecStandardInfo(tecStandardInfo, user);
				// 参与人员修改
				updatePartRankData(tecStandardInfo.getId(), ranks, "21");
			} else {// 普通用户
				tecStandardInfo.setIsValid(1);
				tecStandardInfo.setCreaterId(user.getFax());
				tecStandardInfo.setCreaterName(user.getName());
				tecStandardInfo.setOrgId(user.getBaseOrgId());
				tecStandardInfo.setFlowStatus(0);// 要审批
				addPartRank(ranks, tecStandardInfo.getId(), "21");
				userInfoDao.addTecStandardInfo(tecStandardInfo);
				// 添加流程-add by yangwang 20200803
				workFlowAntService.addWorkFlow(user, t_tec_standard_info, tecStandardInfo.getId(), null, null);
			}
			// 修改插入操作记录
			oldTecStandardInfo.setStandardType(SysDictionaryUtil.getNameByValueForDefault("tecStandardType",
					oldTecStandardInfo.getStandardType()));// 类别
			tecStandardInfo.setStandardType(
					SysDictionaryUtil.getNameByValueForDefault("tecStandardType", tecStandardInfo.getStandardType()));// 级别
			List<TPartRank> tPartRanks = tecStandardInfo.gettPartRankList();
			if (tPartRanks.size() > 0) {
				for (TPartRank rank : tPartRanks) {
					rank.setRoleName(SysDictionaryUtil.getNameByValueForDefault("tecStandardTypeJs", rank.getRole()));
				}
			}
			addRecordLogInfo(tecStandardInfo, oldTecStandardInfo, user, tecStandardInfo.getPrimitiveId(),
					tecStandardInfo.getId(), "2");
		}
		return null;
	}

	public TTecStandardInfo getTecStandardInfoByIdForRecord(String id) {
		TTecStandardInfo tecStandardInfo = userInfoDao.getTecStandardInfoByIdForRecord(id);
		if (tecStandardInfo != null) {
			List<TPartRank> tPartRankList = userInfoDao.getTPartRankByMids(new HashSet<String>() {
				{
					add(id);
				}
			}, "21");
			tecStandardInfo.settPartRankList(tPartRankList);
		}
		return tecStandardInfo;
	}

	public List<TTecStandardInfo> getReadyTecStandardInfoById(String id) {
		return userInfoDao.getReadyTecStandardInfoById(id);
	}


}
